nunjucks-handlebars-template-tag

1.0.1 • Public • Published

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

/nunjucks-handlebars-template-tag/

    Package Sidebar

    Install

    npm i nunjucks-handlebars-template-tag

    Weekly Downloads

    1

    Version

    1.0.1

    License

    MIT

    Unpacked Size

    5.72 kB

    Total Files

    8

    Last publish

    Collaborators

    • vidhill