parcel-plugin-ssg-precompile
v0.1.19
Published
A parcel plugin for precompiling support consolidate.js engine templates
Downloads
6
Readme
parcel-plugin-ssg-precompile
Comapnion plugin for
parcel-plugin-ssg
that adds precompile support for certain template engines.
Usage
Add the plugin to your project as a dependency:
npm install parcel-plugin-ssg-precompile --save
This will generate a precompiled javascript template to allow dynamic re-use in the client. This template is automatically added to the generated HTML via a script tag.
Please see usage instructions specific to the supported template engines:
Nunjucks
To use your precompiled template in the client, you must include the nunjucks
or nunjucks-slim.js
library in your bundle or on the page via a script tag. I.e,
const nunjucks = require('nunjucks');
const updated = nunjucks.render('example-template.js', {title: 'My example page'})
document.innerHTML(updated);
<script>
const nunjucks = require('nunjucks');
const updated = nunjucks.render('example-template.js', {title: 'My example page'})
document.innerHTML(updated);
</script>