Installations
npm install egg-view-static
Developer Guide
Typescript
No
Module System
N/A
Min. Node Version
>=8.0.0
Node Version
8.10.0
NPM Version
5.6.0
Score
66.3
Supply Chain
99.2
Quality
74.2
Maintenance
100
Vulnerability
100
License
Releases
Unable to fetch releases
Contributors
Unable to fetch Contributors
Languages
JavaScript (100%)
Developer
eggjs-community
Download Statistics
Total Downloads
2,453
Last Day
1
Last Week
4
Last Month
15
Last Year
127
GitHub Statistics
5 Stars
3 Commits
14 Watching
1 Branches
7 Contributors
Package Meta Information
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
Total Downloads
Cumulative downloads
Total Downloads
2,453
Last day
0%
1
Compared to previous day
Last week
300%
4
Compared to previous week
Last month
275%
15
Compared to previous month
Last year
-18.1%
127
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dependencies
1
egg-view-static
A simple egg view plugin, allow you to render static html from app/public
.
Install
1$ npm i egg-view-static --save
Usage
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}
Configuration
1// {app_root}/config/config.default.js 2exports.viewStatic = { 3 // cache: true, 4 // replaceFn: (tpl, locals, options) => tpl, 5};
- {Boolean}
cache
- whether cache file, default totrue
exceptlocal
mode. It will share cache withegg-static
LRU cache. - {Function}
replaceFn
- custom render replacement, args =(tpl, locals, options)
see config/config.default.js for more detail.
Example
Questions & Suggestions
Please open an issue here.
License
No vulnerabilities found.
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
project is archived
Details
- Warn: Repository is archived.
Reason
Found 0/3 approved changesets -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
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
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 1 are checked with a SAST tool
Score
3.5
/10
Last Scanned on 2025-01-27
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