1.0.1 • Published 5 years ago
nunjucks-handlebars-template-tag v1.0.1
nunjucks-handlebars-template-tag
Nunjucks custom tag to include raw handlebar templates from external files
$ npm install nunjucks-handlebars-template-tag --saveSetup
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