@wnynya/express-template-engine

0.1.1 • Public • Published

Express Template Engine

Installation

npm i @wnynya/express-template-engine

Usage

import engine from '@wnynya/express-template-engine';

app.engine('html', engine());
app.set('view engine', 'html');
app.set('views', path.resolve(__dirname, './views'));

app.get('/', (req, res) => {
  res.render('template', {});
});

Variable Injection

<span>#{val}</span>

<eval> Tag

<eval>variable</eval>
<eval>javascript.code({});</eval>

<repeat> Tag

<repeat index="i" from="0" to="5">
  <p>Run #{i} times.</p>
</repeat>
<repeat index="i" times="5">
  <p>Run <eval>i</eval> times.</p>
</repeat>

<if>, <elif>, <else> Tag

<if condition="false">
  <p>Content of IF</p>
</if>
<elif condition="val == 'cond'">
  <p>Content of ELIF</p>
</elif>
<else>
  <p>Content of ELSE</p>
</else>

<import> Tag

<import src="another/template"></import>

Readme

Keywords

Package Sidebar

Install

npm i @wnynya/express-template-engine

Weekly Downloads

4

Version

0.1.1

License

none

Unpacked Size

8.08 kB

Total Files

9

Last publish

Collaborators

  • wnynya