Nunjucks extension that allows send data to include template.
npm install nunjucks-include-with
// CommonJS
// const IncludeWithNunjucksExtension = require('nunjucks-include-with');
// ES6
import IncludeWithNunjucksExtension from 'nunjucks-include-with';
import nunjucks from 'nunjucks';
// Registration
const nunjucksEnv = nunjucks.configure('views');
nunjucksEnv.addExtension('includeWith', new IncludeWithNunjucksExtension({
nunjucksEnv
}));
//Template
{% includeWith "../partial.tpl", { name: 'Test' } %}
IncludeWithNunjucksExtension({Object})
{% includeWith {String}, {Object}, {Object} %}
Name |
Type |
Default |
Description |
templatePath |
String |
|
Path of the included template. |
data |
Object |
{} |
Object with the data for the included template. |
options |
Object |
{ useContext = true } |
Option to include the global context. |
- Fork it:
git clone https://github.com/softonic/nunjucks-include-with.git
- Create your feature branch:
git checkout -b feature/my-new-feature
- Commit your changes:
git commit -am 'Added some feature'
- Check the build:
npm run build
- Push to the branch:
git push origin my-new-feature
- Submit a pull request :D