@themost/ejs
TypeScript icon, indicating that this package has built-in type declarations

2.0.1 • Public • Published

@themost/ejs

EJS view engine extension for supporting layouts

Installation

npm i @themost/ejs

Usage

Register EJS view engine extension for Express.js

import express from 'express';
import path from 'path';
import {ViewEngine} from '@themost/ejs';

const app = express();
// set ejs engine
app.engine('ejs', ViewEngine.express());
app.set('view engine', 'ejs');
// resolve views root path
app.set('views', path.resolve(__dirname, './views'));

And start using ejs layouts:

layout.ejs

<!DOCTYPE html>
<html>
    <head>
    </head>
    <body>
        <%- body %>
    </body>
</html>

page.ejs

<% layout('master') %>
<div>
    <h1>My First Message</h1>
    <p><%=message%></p>
</div>

Package Sidebar

Install

npm i @themost/ejs

Weekly Downloads

3

Version

2.0.1

License

BSD-3-Clause

Unpacked Size

12 kB

Total Files

16

Last publish

Collaborators

  • themost