A tool that allows you to compile static HTML templates so you could import them from a module.
meteor add urigo:static-html-compiler
If you are looking for a package with a working implementation of this tool you should check static-templates
.
import {
MainHtmlCompiler, // body, head
TemplateHtmlCompiler, // templates
StaticHtmlCompiler,
utils,
} from 'meteor/urigo:static-html-compiler';
class TemplateCacheCompiler extends TemplateHtmlCompiler {
compileContents(file, contents) {
const template = utils.clean(contents);
return `module.exports = "${template}"`;
}
}
Plugin.registerCompiler({
extensions: ['html']
}, () => new StaticHtmlCompiler(new MainHtmlCompiler, new TemplateCacheCompiler));
Compiles a html file to a string by default
It is possible to change the way StaticHtmlCompiler
works by providing custom MainHtmlCompiler
and TemplateHtmlCompiler
.
Handles files that contain <head/>
or <body/>
tag.
Handles files that do not contain <head/>
and <body/>
tags.
Returns contents of a ES6 module that will be later compiled from a string to JavaScript code.
Cleans up HTML.
Minifies HTML.