ejs-next

1.8.0 • Public • Published

ejs-next

Coverage Status

EJS next generation


Install

npm install ejs-next

Changes

  • Using async actions with promises (on files actions)
  • Improved performances on parser
  • Introduce a new JS tags for capturing outputs
  • Introduce new functions : layout & block

Syntax

The syntax is the same as classic EJS, with the introduction of a little new content wrapper :

  • {@ : start to capture output
  • @} : returns the captured output

Usage :

<html>
... <%- include('foo.ejs', {
      inner: function(name) => {@
        %>
          Hello <%= name %>
        <%
      @}
    }) %>
</html>
--- and foo.ejs :
<%= inner('John Smith'); %>

Layout

The layout will replace the output with the specified file, and put the current output into a contents variable.

<%_ layout('main') _%>
Here is my page content
--- main.ejs :
<body>
  <%- contents %>
</body>

Block

The block registers/concatenate the specified output in order to output it elsewhere. Note that by using promise actions the orders in which statements are called may not be preserved.

<%_ block('js', '<script src="...">') _%>
Here is my page content
--- main.ejs :
<body>
  <%- js %>
</body>

Express usage

var ejs = require("ejs-next");
app.set("views", path.join(__dirname, "views"));
app.engine("ejs", ejs.__express);
app.set("view engine", "ejs");

IDE Integration with Syntax Highlighting

VSCode:Javascript EJS by DigitalBrainstem

Related projects

There are a number of implementations of EJS:

License

MIT License - Copyright (c) 2022 Ioan CHIRIAC

Readme

Keywords

Package Sidebar

Install

npm i ejs-next

Weekly Downloads

0

Version

1.8.0

License

MIT

Unpacked Size

124 kB

Total Files

13

Last publish

Collaborators

  • ichiriac