Installations
npm install gulp-nunjucks-render
Score
78.2
Supply Chain
99.4
Quality
76
Maintenance
100
Vulnerability
99.6
License
Releases
Unable to fetch releases
Developer
carlosl
Developer Guide
Module System
Unable to determine the module system for this package.
Min. Node Version
>=0.10.0
Typescript Support
No
Node Version
8.11.0
NPM Version
5.6.0
Statistics
148 Stars
112 Commits
33 Forks
9 Watching
3 Branches
21 Contributors
Updated on 27 Nov 2024
Bundle Size
195.47 kB
Minified
59.16 kB
Minified + Gzipped
Languages
JavaScript (92.83%)
HTML (5.83%)
Smarty (1.34%)
Total Downloads
Cumulative downloads
Total Downloads
2,636,653
Last day
29.3%
1,984
Compared to previous day
Last week
7.6%
8,437
Compared to previous week
Last month
37%
30,336
Compared to previous month
Last year
-6.9%
309,204
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dependencies
5
gulp-nunjucks-render
Render Nunjucks templates
Issues with the output should be reported on the Nunjucks issue tracker.
Install
Install with npm
npm install --save-dev gulp-nunjucks-render
Example
1var gulp = require('gulp'); 2var nunjucksRender = require('gulp-nunjucks-render'); 3 4gulp.task('default', function () { 5 return gulp.src('src/templates/*.html') 6 .pipe(nunjucksRender({ 7 path: ['src/templates/'] // String or Array 8 })) 9 .pipe(gulp.dest('dist')); 10});
Example with gulp data
1var gulp = require('gulp'); 2var nunjucksRender = require('gulp-nunjucks-render'); 3var data = require('gulp-data'); 4 5function getDataForFile(file) { 6 return { 7 example: 'data loaded for ' + file.relative 8 }; 9} 10 11gulp.task('default', function () { 12 return gulp.src('src/templates/*.html') 13 .pipe(data(getDataForFile)) 14 .pipe(nunjucksRender({ 15 path: 'src/templates' 16 })) 17 .pipe(gulp.dest('dist')); 18});
API
Options
Plugin accepts options object, which contain these by default:
1var defaults = { 2 path: '.', 3 ext: '.html', 4 data: {}, 5 inheritExtension: false, 6 envOptions: { 7 watch: false 8 }, 9 manageEnv: null, 10 loaders: null 11};
path
- Relative path to templatesext
- Extension for compiled templates, pass null or empty string if yo don't want any extensiondata
- Data passed to templateinheritExtension
- If true, uses same extension that is used for templateenvOptions
- These are options provided for nunjucks Environment. More info here.manageEnv
- Hook for managing environment before compilation. Useful for adding custom filters, globals, etc. Example belowloaders
- If provided, uses that as first parameter to Environment constructor. Otherwise, uses providedpath
. More info here
For more info about nunjucks functionality, check https://mozilla.github.io/nunjucks/api.html and also a source code of this plugin.
Data
U can pass data as option, or you can use gulp-data like in example above.
1nunjucksRender({data: {
2 css_path: 'http://company.com/css/'
3}});
For the following template
1<link rel="stylesheet" href="{{ css_path }}test.css" />
Would render
1<link rel="stylesheet" href="http://company.com/css/test.css" />
Environment
If you want to manage environment (add custom filters or globals), you can to that with manageEnv
function hook:
1var manageEnvironment = function(environment) { 2 environment.addFilter('slug', function(str) { 3 return str && str.replace(/\s/g, '-', str).toLowerCase(); 4 }); 5 6 environment.addGlobal('globalTitle', 'My global title') 7} 8 9nunjucksRender({ 10 manageEnv: manageEnvironment 11}):
After adding that, you can use them in template like this:
1<h1>{{ globalTitle }}</h1> 2<h3>{{ 'My important post'|slug }}</h3>
And get this result:
1<h1>My global title</h1> 2<h3>my-important-post</h3>
License
MIT © Carlos G. Limardo and Kristijan Husak
Shout-outs
Sindre Sorhus who wrote the original gulp-nunjucks for precompiling Nunjucks templates. I updated his to render instead of precompile.
kristijanhusak for bug fixes and help with maintenance.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
Found 8/16 approved changesets -- score normalized to 5
Reason
5 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-93q8-gq69-wqmw
- Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg
- Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3
- Warn: Project is vulnerable to: GHSA-qrpm-p2h7-hrv2
- Warn: Project is vulnerable to: GHSA-x77j-w7wf-fjmw
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
license file not detected
Details
- Warn: project does not have a license file
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 23 are checked with a SAST tool
Score
2.6
/10
Last Scanned on 2024-11-25
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn MoreOther packages similar to gulp-nunjucks-render
nunjucks
A powerful templating engine with inheritance, asynchronous control, and more (jinja2 inspired)
gulp-nunjucks
Compile/precompile Nunjucks templates
@types/nunjucks
TypeScript definitions for nunjucks
@visual-framework/vf-extensions
Reusable componentised code, modules and config for vf-eleventy based projects.