npm

nunjucks-component-extension

0.0.7 • Public • Published

nunjucks-component-extension

nunjucks plugin for pass data

install

npm install nunjucks-component-extension --save

use case

const nunjucks = require('nunjucks');
const env = new nunjucks.configure(config.cwd);
 
env.addExtension('ComponentExtension', require('nunjucks-component-extension'));
 
nunjucks.render('index.html', (err, str) => {
    console.log(str);
})

ex.

index.html:

<html>
<head>
    <title>test component</title>
</head>
<body>
    {%
        set obj = {
            name: 'Michael',
            corp: 'Alibaba',
            dep: '神马搜索'
        }
    %}
 
    {% component file="sub.html", obj%}
</body>
</html>

sub.html:

<p>姓名: {{name}}</p>
<p>公司: {{corp}}</p>

Dependents (1)

Package Sidebar

Install

npm i nunjucks-component-extension

Weekly Downloads

1

Version

0.0.7

License

ISC

Last publish

Collaborators

  • hacke2
  • mingzhi22