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
Module System
Unable to determine the module system for this package.
Min. Node Version
Typescript Support
Node Version
NPM Version
89 Stars
46 Commits
9 Forks
11 Watching
1 Branches
23 Contributors
Updated on 10 Sept 2024
JavaScript (100%)
Cumulative downloads
Total Downloads
Last day
-3.2%
510
Compared to previous day
Last week
-2.3%
3,389
Compared to previous week
Last month
3.4%
14,907
Compared to previous month
Last year
7%
177,468
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
license file detected
Details
Reason
0 existing vulnerabilities detected
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 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 More