Installations
npm install koa-ejs
Developer Guide
Typescript
No
Module System
CommonJS
Node Version
10.16.0
NPM Version
6.12.0
Score
77.2
Supply Chain
95.8
Quality
75.3
Maintenance
25
Vulnerability
100
License
Releases
Contributors
Unable to fetch Contributors
Languages
JavaScript (96.03%)
HTML (3.97%)
Developer
koajs
Download Statistics
Total Downloads
2,740,891
Last Day
725
Last Week
4,537
Last Month
27,988
Last Year
397,894
GitHub Statistics
249 Stars
94 Commits
56 Forks
8 Watching
9 Branches
30 Contributors
Bundle Size
21.64 kB
Minified
8.17 kB
Minified + Gzipped
Package Meta Information
Latest Version
4.3.0
Package Id
koa-ejs@4.3.0
Size
4.46 kB
NPM Version
6.12.0
Node Version
10.16.0
Publised On
04 Dec 2019
Total Downloads
Cumulative downloads
Total Downloads
2,740,891
Last day
-36.3%
725
Compared to previous day
Last week
-40.8%
4,537
Compared to previous week
Last month
-0.5%
27,988
Compared to previous month
Last year
-6.9%
397,894
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
koa-ejs
Koa ejs view render middleware. support all feature of ejs.
Usage
Example
1const Koa = require('koa'); 2const render = require('koa-ejs'); 3const path = require('path'); 4 5const app = new Koa(); 6render(app, { 7 root: path.join(__dirname, 'view'), 8 layout: 'template', 9 viewExt: 'html', 10 cache: false, 11 debug: true 12}); 13 14app.use(async function (ctx) { 15 await ctx.render('user'); 16}); 17 18app.listen(7001);
Or you can checkout the example.
settings
- root: view root directory.
- layout: global layout file, default is
layout
, setfalse
to disable layout. - viewExt: view file extension (default
html
). - cache: cache compiled templates (default
true
). - debug: debug flag (default
false
). - delimiter: character to use with angle brackets for open / close (default
%
). - async: When true, EJS will use an async function for rendering. Depends on async/await support in the JS runtime.
- outputFunctionName: Set to a string (e.g., 'echo' or 'print') for a function to print output inside scriptlet tags.
Layouts
koa-ejs
supports layouts. The default layout file is layout
. If you want to change default layout file, use settings.layout
. Also you can specify layout by options.layout
in await ctx.render
.
Also you can set layout = false
to disable the layout.
<html>
<head>
<title>koa ejs</title>
</head>
<body>
<h3>koa ejs</h3>
<%- body %>
</body>
</html>
Include
Supports ejs includes.
<div>
<% include user.html %>
</div>
State
Support ctx.state
in koa.
Licences
(The MIT License)
Copyright (c) 2017 dead-horse and other contributors
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
![Empty State](/_next/static/media/empty.e5fae2e5.png)
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
security policy file detected
Details
- Info: security policy file detected: github.com/koajs/.github/SECURITY.md:1
- Info: Found linked content: github.com/koajs/.github/SECURITY.md:1
- Info: Found disclosure, vulnerability, and/or timelines in security policy: github.com/koajs/.github/SECURITY.md:1
- Info: Found text in security policy: github.com/koajs/.github/SECURITY.md:1
Reason
Found 7/17 approved changesets -- score normalized to 4
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
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 21 are checked with a SAST tool
Score
5.1
/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