1.0.5 • Published 6 years ago

nunjucks-include-with v1.0.5

Weekly downloads
6
License
Apache-2.0
Repository
github
Last release
6 years ago

nunjucks-include-with

Nunjucks extension that allows send data to include template.

Installation

npm install nunjucks-include-with

Usage

// 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' } %}

Extension Options

IncludeWithNunjucksExtension({Object})

NameTypeDefaultDescription
nunjucksEnvEnvironmentInstance of Nunjucks environment. https://mozilla.github.io/nunjucks/api.html#environment
tagNameStringincludeWithName for the tag in the template.

Template Options

{% includeWith {String}, {Object}, {Object} %}

NameTypeDefaultDescription
templatePathStringPath of the included template.
dataObject{}Object with the data for the included template.
optionsObject{ useContext = true }Option to include the global context.

Contribute

  1. Fork it: git clone https://github.com/softonic/nunjucks-include-with.git
  2. Create your feature branch: git checkout -b feature/my-new-feature
  3. Commit your changes: git commit -am 'Added some feature'
  4. Check the build: npm run build
  5. Push to the branch: git push origin my-new-feature
  6. Submit a pull request :D
1.0.5

6 years ago

1.0.4

6 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago