Installations
npm install gulp-nunjucks
Developer
sindresorhus
Developer Guide
Module System
ESM
Min. Node Version
>=18
Typescript Support
No
Node Version
18.18.2
NPM Version
9.2.0
Statistics
153 Stars
71 Commits
19 Forks
6 Watching
1 Branches
11 Contributors
Updated on 08 Sept 2024
Languages
JavaScript (100%)
Total Downloads
Cumulative downloads
Total Downloads
782,230
Last day
-4.5%
1,062
Compared to previous day
Last week
5.5%
5,372
Compared to previous week
Last month
134%
15,916
Compared to previous month
Last year
-3.8%
104,475
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
gulp-nunjucks
Compile/precompile Nunjucks templates
Issues with the output should be reported on the Nunjucks issue tracker.
Install
1npm install --save-dev gulp-nunjucks
Usage
Compile
1import gulp from 'gulp'; 2import {nunjucksCompile} from 'gulp-nunjucks'; 3 4export default () => ( 5 gulp.src('templates/greeting.html') 6 .pipe(nunjucksCompile({name: 'Sindre'})) 7 .pipe(gulp.dest('dist')) 8);
You can alternatively use gulp-data to inject the data:
1import gulp from 'gulp'; 2import {nunjucksCompile} from 'gulp-nunjucks'; 3import data from 'gulp-data'; 4 5export default () => ( 6 gulp.src('templates/greeting.html') 7 .pipe(data(() => ({name: 'Sindre'}))) 8 .pipe(nunjucksCompile()) 9 .pipe(gulp.dest('dist')) 10);
Precompile
1import gulp from 'gulp'; 2import {nunjucksPrecompile} from 'gulp-nunjucks'; 3 4export default () => ( 5 gulp.src('templates/greeting.html') 6 .pipe(nunjucksPrecompile()) 7 .pipe(gulp.dest('dist')) 8);
API
nunjucksCompile(data?, options?)
Compile a template using the provided data
.
data
Type: object
The data object used to populate the text.
options
Type: object
Options will be passed directly to the Nunjucks Environment constructor which will be used to compile templates.
options.env
Type: nunjucks.Environment
Default: new nunjucks.Environment()
The custom Nunjucks Environment object which will be used to compile templates. If supplied, the rest of options
will be ignored.
options.filters
Type: object
An object containing custom filters that will be passed to Nunjucks, with the filter's name as key and the filter function as value.
Async filters should be defined as async functions. You cannot use just a promise-returning function.
1{ 2 'shorten': string => string.slice(0, 5), 3 'round': number => Math.round(number), 4 'fetch': async url => { 5 const response = await fetch(url); 6 const result = await response.text(); 7 return result; 8 } 9}
nunjucksPrecompile(options?)
Precompile a template for rendering dynamically at a later time.
Same options as nunjucks.precompile()
except for name
.
options
Type: object
name
Type: Function
Default: Relative template path
Example: templates/list.html
You can override the default behavior by supplying a function which gets the current File object and is expected to return the name.
Example:
1{ 2 name: file => `template-${file.relative}` 3}
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
- Info: project has a license file: license:0
- Info: FSF or OSI recognized license: MIT License: license:0
Reason
Found 5/30 approved changesets -- score normalized to 1
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
- Warn: no topLevel permission defined: .github/workflows/main.yml:1
- Info: no jobLevel write permissions found
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/main.yml:16: update your workflow using https://app.stepsecurity.io/secureworkflow/sindresorhus/gulp-nunjucks/main.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/main.yml:17: update your workflow using https://app.stepsecurity.io/secureworkflow/sindresorhus/gulp-nunjucks/main.yml/main?enable=pin
- Warn: npmCommand not pinned by hash: .github/workflows/main.yml:21
- Info: 0 out of 2 GitHub-owned GitHubAction dependencies pinned
- Info: 0 out of 1 npmCommand dependencies pinned
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'main'
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
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 5 are checked with a SAST tool
Score
3.5
/10
Last Scanned on 2024-11-18
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 More