ejs-addon
Addon for EJS 2.x and Express 4.x
Install
npm i ejs-addon -S
Usage
Explains the usages of ejs-addon
, you can view detail usages in example.
layout
layout
refers to ejs-mate
- Declare layout
ejs-addon<%- body %>
- Use layout
<% layout('default') %> <h1>Title</h1>
- Working with Express
const app = ;const engine = ; app; app;app;
loader
- Use
loader
<% loader([ '/path/to/foo.css', '/path/to/bar.js']) %>
- Declare placeholder in layout
ejs-addon
use <%- css %>
and <%- js %>
, put them in the right place.
ejs-addon <%- css %><%- body %><%- js %>
loader
More about loader
support adding prefix for assets.
For example, if you are using CDN for your application in production, follow these steps:
- Ensure
process.env.NODE_ENV === 'productoin'
- Use the following lines of codes in your
app.js
:
// Pulic folderapp;// Declare CDN url patternapp;
Things about CDN pattern:
@version
would be replaced with the file's modified time@path
would be replaced with the files relative file path as you declared inloader()
Example
See example
Contribute
Fire an issue
License
The MIT License