Installations
npm install @koa/ejs
Developer Guide
Typescript
No
Module System
CommonJS
Node Version
16.18.1
NPM Version
8.19.2
Score
77
Supply Chain
94.5
Quality
82.2
Maintenance
100
Vulnerability
100
License
Releases
Contributors
Unable to fetch Contributors
Languages
JavaScript (96.03%)
HTML (3.97%)
Developer
koajs
Download Statistics
Total Downloads
332,888
Last Day
2,130
Last Week
8,847
Last Month
30,343
Last Year
281,757
GitHub Statistics
249 Stars
94 Commits
56 Forks
8 Watching
9 Branches
30 Contributors
Bundle Size
18.91 kB
Minified
7.12 kB
Minified + Gzipped
Package Meta Information
Latest Version
5.1.0
Package Id
@koa/ejs@5.1.0
Unpacked Size
7.92 kB
Size
3.51 kB
File Count
4
NPM Version
8.19.2
Node Version
16.18.1
Publised On
02 Mar 2023
Total Downloads
Cumulative downloads
Total Downloads
332,888
Last day
12.6%
2,130
Compared to previous day
Last week
8.2%
8,847
Compared to previous week
Last month
45%
30,343
Compared to previous month
Last year
508.3%
281,757
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.
- fs: file system module with same Node.js fs interface (default
Node.js fs module
). - 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.
TypeScript
If you're project based on TypeScript, we recommend using @types/koa-ejs
until we start supporting it in the upcoming releases.
Licences
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