Multi Mustache loader for webpack
Compiles Mustache templates with Hogan and optionally html-minifier. Support both single template file and multi template file.
the multi template file should only write as below:
<script type="template/text" id="tmp-multi-a"></script>
<script type="template/text" id="tmp-multi-b"></script>
$ npm i multi-mustache-loader
module: {
loaders: [ {
test: /\.html$/,
loader: 'multi-mustache'
// loader: 'multi-mustache?minify'
// loader: 'multi-mustache?{ minify: { removeComments: false } }'
// loader: 'multi-mustache?noShortcut'
} ]
}
template.html
<ul>
{{#user}}
<li>{{name}}</li>
{{/user}}
</ul>
var template = require('./template.html');
var html = template({ foo: 'bar' });
multi-template.html
<script type="template/text" id="tmp-name">
<span>{{name}}</span>
</script>
<script type="template/text" id="tmp-post">
<span>{{post}}</span>
</script>
var template = require('./multi-template.html');
var htmlName = template['tmp-name']({ name: 'multi-mustache-loader' });
var htmlPost = template['tmp-post']({post:'hello multi-mustache-loader!'});
If noShortcut
is passed, then Hogan compiled template is returned instead, so
you can pass it as partial.
var template = require('./template.html');
var template2 = require('./template2.html');
var html = template({ foo: 'bar' }, {partial: template2});
MIT