Gathering detailed insights and metrics for egg-view-static
Gathering detailed insights and metrics for egg-view-static
Gathering detailed insights and metrics for egg-view-static
Gathering detailed insights and metrics for egg-view-static
just a simple plugin for egg view, to render static file from public directory
npm install egg-view-static
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
5 Stars
3 Commits
13 Watchers
1 Branches
6 Contributors
Updated on Jan 28, 2023
Latest Version
1.0.0
Package Id
egg-view-static@1.0.0
Unpacked Size
7.17 kB
Size
3.04 kB
File Count
8
NPM Version
5.6.0
Node Version
8.10.0
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
A simple egg view plugin, allow you to render static html from app/public
.
1$ npm i egg-view-static --save
1// {app_root}/config/plugin.js 2exports.viewStatic = { 3 enable: true, 4 package: 'egg-view-static', 5};
Set mapping in config
1// {app_root}/config/config.default.js 2exports.view = { 3 defaultViewEngine: 'static', 4 mapping: { 5 '.html': 'static', 6 }, 7};
Render in controller
1// {app_root}/app/controller/home.js 2class HomeController extends Controller { 3 async index() { 4 // app/static/index.html 5 await this.ctx.render('index.html'); 6 } 7}
Use replaceFn
to custom render with locals, see test/fixtures/apps/locals/config/config.default.js for more detail.
1// {app_root}/config/config.default.js 2config.viewStatic = { 3 replaceFn(tpl, locals) { 4 return tpl.toString().replace(/(\\)?{{ *(\w+) *}}/g, (block, skip, key) => { 5 if (skip) { 6 return block.substring(skip.length); 7 } 8 return locals.hasOwnProperty(key) ? locals[key] : block; 9 }); 10 }, 11}; 12 13// {app_root}/app/controller/home.js 14class HomeController extends Controller { 15 async index() { 16 // app/static/index.html 17 await this.ctx.render('index.html', { name: 'egg' }); 18 } 19}
1// {app_root}/config/config.default.js 2exports.viewStatic = { 3 // cache: true, 4 // replaceFn: (tpl, locals, options) => tpl, 5};
cache
- whether cache file, default to true
except local
mode. It will share cache with egg-static
LRU cache.replaceFn
- custom render replacement, args = (tpl, locals, options)
see config/config.default.js for more detail.
Please open an issue here.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
Found 0/3 approved changesets -- score normalized to 0
Reason
project is archived
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
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