1.8.0 • Published 1 year ago

ejs-next v1.8.0

Weekly downloads
2
License
MIT
Repository
github
Last release
1 year ago

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

1.8.0

1 year ago

1.7.0

1 year ago

1.6.0

2 years ago

1.5.0

5 years ago

1.4.0

5 years ago

1.3.2

5 years ago

1.3.1

5 years ago

1.3.0

5 years ago

1.2.0

5 years ago

1.1.0

5 years ago

1.0.0

5 years ago