1.1.6 • Published 7 months ago

mojo-plugin-ejs v1.1.6

Weekly downloads
-
License
MIT
Repository
github
Last release
7 months ago

npm.io Coverage Status npm

A mojo.js plugin that adds support for ejs templates. The code of this plugin is a good example for learning to build new plugins, you're welcome to fork it.

import mojo from '@mojojs/core';
import ejsPlugin from 'mojo-plugin-ejs';

const app = mojo();
app.plugin(ejsPlugin);

// Render template "views/index.html.ejs"
app.get('/template', async ctx => {
  await ctx.render({view: 'index'});
});

// Render an inline ejs template
app.get('/inline', async ctx => {
  await ctx.render({inline: '<%- greeting %> World!', engine: 'ejs'}, {greeting: 'Hello'});
});

app.start();

To change the default engine for inline templates you can also set app.renderer.defaultEngine to ejs. Or you can register the template engine with a completely different name.

app.plugin(ejsPlugin, {name: 'foo'});
app.renderer.defaultEngine = 'foo';

Installation

All you need is Node.js 16.0.0 (or newer).

$ npm install mojo-plugin-ejs

Support

If you have any questions the documentation might not yet answer, don't hesitate to ask in the Forum, on Matrix, or IRC.

1.1.6

7 months ago

1.1.5

7 months ago

1.1.4

1 year ago

1.1.3

1 year ago

1.1.2

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago