
Security News
Security Community Slams MIT-linked Report Claiming AI Powers 80% of Ransomware
Experts push back on new claims about AI-driven ransomware, warning that hype and sponsored research are distorting how the threat is understood.
gulp-nunjucks-api
Advanced tools
Render Nunjucks templates with data, custom filters, custom context functions and options for other Nunjucks API features.
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
var gulp = require('gulp');
var nunjucksRender = require('gulp-nunjucks-api');
gulp.task('default', function () {
  return gulp.src('src/templates/*.html')
    .pipe(nunjucksRender({
		  src: 'src/templates',
      data: require('./global-data.json'),
      filters: require('./global-filters.js'),
      functions: require('./global-functions.js')
		}))
		.pipe(gulp.dest('dist'));
});
var gulp = require('gulp');
var nunjucksRender = require('gulp-nunjucks-api');
var data = require('gulp-data');
function getDataForFile(file){
  return {
    example: 'data loaded for ' + file.relative
  };
}
gulp.task('default', function () {
	return gulp.src('src/templates/*.html')
	  .pipe(data(getDataForFile))
		.pipe(nunjucksRender({
      src: 'src/templates/'
    }))
		.pipe(gulp.dest('dist'));
});
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.
FAQs
Render Nunjucks templates with data, custom filters, custom context functions and options for other Nunjucks API features.
The npm package gulp-nunjucks-api receives a total of 48 weekly downloads. As such, gulp-nunjucks-api popularity was classified as not popular.
We found that gulp-nunjucks-api demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Experts push back on new claims about AI-driven ransomware, warning that hype and sponsored research are distorting how the threat is understood.

Security News
Ruby's creator Matz assumes control of RubyGems and Bundler repositories while former maintainers agree to step back and transfer all rights to end the dispute.

Research
/Security News
Socket researchers found 10 typosquatted npm packages that auto-run on install, show fake CAPTCHAs, fingerprint by IP, and deploy a credential stealer.