@wnynya/express-template-engine
v0.1.1
Published
HTML template engine for express
Downloads
1
Readme
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>