nunjucks-handlebars-template-tag
v1.0.1
Published
Custom nunjucks tag to include handlebar templates
Downloads
4
Readme
nunjucks-handlebars-template-tag
Nunjucks custom tag to include raw handlebar templates from external files
$ npm install nunjucks-handlebars-template-tag --save
Setup
const nunjucks = require('nunjucks');
const { IncludeHandlebarsTemplate } = require('nunjucks-handlebars-template-tag');
const fileSystem = new nunjucks.FileSystemLoader('views');
const env = new nunjucks.Environment(fileSystem);
env.addExtension('IncludeHandlebarsTemplate', new IncludeHandlebarsTemplate());
Usage
{% includeHandleBarsTemplate "includes/my-template.handlebars" %}
Outputs
<script id="my-template" type="text/x-handlebars-template">
// raw content of includes/my-template.handlebars
</script>
Note the id
of the script matches the filename of the included file, this is by design