Socket
Socket
Sign inDemoInstall

express-template-engine

Package Overview
Dependencies
11
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    express-template-engine

Easy HTML-based template engine for Express


Version published
Weekly downloads
32
increased by28%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

Express Template Engine

Easy HTML-based template engine for Express

You can see tutorial here.

Installation

npm i express-template-engine

Setup with Express

import engine from 'express-template-engine'; // ESM, Typescript
const engine = require('express-template-engine'); // CJS

// Set express template engine
app.engine('html', engine({ caching: false }));
app.set('view engine', 'html');

// Set views directory
app.set('views', path.resolve(__dirname, './views'));

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

Function Tags

<eval> Tag

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

Variable Injection (Same as <eval> Tag)

<span>#{val}</span>

<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>

Keywords

FAQs

Last updated on 23 Mar 2024

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc