Gathering detailed insights and metrics for egg-view-nunjucks
Gathering detailed insights and metrics for egg-view-nunjucks
Gathering detailed insights and metrics for egg-view-nunjucks
Gathering detailed insights and metrics for egg-view-nunjucks
npm install egg-view-nunjucks
Typescript
Module System
Min. Node Version
Node Version
NPM Version
JavaScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
89 Stars
46 Commits
9 Forks
10 Watchers
1 Branches
24 Contributors
Updated on Sep 10, 2024
Latest Version
2.3.0
Package Id
egg-view-nunjucks@2.3.0
Size
6.13 kB
NPM Version
6.14.7
Node Version
12.19.0
Published on
Jan 14, 2021
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
1
nunjucks view plugin for egg.
1$ npm i egg-view-nunjucks --save
1// {app_root}/config/plugin.js 2exports.nunjucks = { 3 enable: true, 4 package: 'egg-view-nunjucks', 5};
Set mapping in config
1// {app_root}/config/config.default.js 2exports.view = { 3 defaultViewEngine: 'nunjucks', 4 mapping: { 5 '.nj': 'nunjucks', 6 }, 7};
Render in controller
1// {app_root}/app/controller/test.js 2class TestController extends Controller { 3 async list() { 4 const ctx = this.ctx; 5 // ctx.body = await ctx.renderString('{{ name }}', { name: 'local' }); 6 // not need to assign `ctx.render` to `ctx.body` 7 // https://github.com/mozilla/nunjucks/blob/6f3e4a36a71cfd59ddc8c1fc5dcd77b8c24d83f3/nunjucks/src/environment.js#L318 8 await ctx.render('test.nj', { name: 'view test' }, { 9 path: '***' 10 }); 11 } 12}
escape
filter is replaced by helper.escape
which is provided by egg-security
for better performanceapp/extend/filter.js
, then they will be injected automatically to nunjucks1// {app_root}/app/extend/filter.js 2exports.hello = name => `hi, ${name}`; 3 4// so you could use it at template 5// {app_root}/app/controller/test.js 6class TestController extends Controller { 7 async list() { 8 const ctx = this.ctx; 9 ctx.body = await ctx.renderString('{{ name | hello }}', { name: 'egg' }, { 10 path: '***' 11 }); 12 }; 13}
you can extend custom tag like this:
1// {app_root}/app.js 2const markdown = require('nunjucks-markdown'); 3const marked = require('marked'); 4 5module.exports = app => { 6 markdown.register(app.nunjucks, marked); 7};
see egg-security
_csrf
attr to form fieldnonce
attr to script taghelper/ctx/request
in template, such as helper.shtml('<div></div>')
helper.upper('test')
helper.shtml/surl/sjs/escape
is auto wrapped with safe
app.nunjucks
- nunjucks environmentapp.nunjucks.cleanCache(fullPath/tplName)
to easy clean cache, can use with custom egg-watchersee config/config.default.js for more detail.
Please open an issue here.
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
Reason
Found 16/30 approved changesets -- score normalized to 5
Reason
dependency not pinned by hash detected -- score normalized to 3
Details
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
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
security policy file not detected
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2025-07-07
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