Gathering detailed insights and metrics for gulp-nunjucks-api
Gathering detailed insights and metrics for gulp-nunjucks-api
Gathering detailed insights and metrics for gulp-nunjucks-api
Gathering detailed insights and metrics for gulp-nunjucks-api
npm install gulp-nunjucks-api
Typescript
Module System
Min. Node Version
Node Version
NPM Version
66.1
Supply Chain
95.7
Quality
71.7
Maintenance
100
Vulnerability
98.2
License
Total Downloads
64,051
Last Day
11
Last Week
60
Last Month
220
Last Year
2,732
Minified
Minified + Gzipped
Latest Version
0.9.1
Package Id
gulp-nunjucks-api@0.9.1
Unpacked Size
15.12 kB
Size
5.19 kB
File Count
4
NPM Version
6.13.1
Node Version
13.2.0
Cumulative downloads
Total Downloads
Last Day
-52.2%
11
Compared to previous day
Last Week
-15.5%
60
Compared to previous week
Last Month
11.7%
220
Compared to previous month
Last Year
-73.1%
2,732
Compared to previous year
Render Nunjucks templates with data, custom filters, custom context functions and options for other Nunjucks API features.
Install with npm
npm install --save-dev gulp-nunjucks-api
1var gulp = require('gulp'); 2var nunjucksRender = require('gulp-nunjucks-api'); 3 4gulp.task('default', function () { 5 return gulp.src('src/templates/*.html') 6 .pipe(nunjucksRender({ 7 src: 'src/templates', 8 data: require('./global-data.json'), 9 filters: require('./global-filters.js'), 10 functions: require('./global-functions.js') 11 })) 12 .pipe(gulp.dest('dist')); 13});
1var gulp = require('gulp'); 2var nunjucksRender = require('gulp-nunjucks-api'); 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 src: 'src/templates/' 16 })) 17 .pipe(gulp.dest('dist')); 18});
Renders source templates using the given options to configure the Nunjucks API with custom data, extensions, filters and contextual functions.
Same options as
nunjucks.configure()
:
With the following additional options:
nunjucks.configure()
.false
to let the gulp task continue on errors. See also: the verbose
option.data
, extensions
, filters
and functions
objects instead of setting
each of these options separately. The separate global options are merged into
this base object.true
, enables
loading of local template context data and functions from files that match
the following default pattern: "<filename>.+(js|json)"
. When a
glob pattern
string is given, the directory containing a given template will be searched
using the pattern. Data and functions from all matched files are merged into
the render context. Note that the token <filename>
will be replaced with a
given template's file name including extension. Use the <filename_noext>
token instead in a custom pattern to target the file name without extension.true
, detailed operational
data is logged to the console.nunjucksRender({
data: {css_path: 'http://company.com/css/'}
});
For the following template
<link rel="stylesheet" href="{{ css_path }}test.css" />
Would render
<link rel="stylesheet" href="http://company.com/css/test.css" />
Nunjucks' watch feature, which is normally enabled by default, is disabled by
default for gulp. Pass watch: true
to enable it:
nunjucksRender({
src: './source',
watch: true
});
MIT © Devoptix LLC
Carlos G. Limardo who wrote gulp-nunjucks-render which I am forking in order to update Nunjucks and do other stuff.
Sindre Sorhus who wrote the original gulp-nunjucks for precompiling Nunjucks templates.
No vulnerabilities found.
No security vulnerabilities found.