New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

templating-engine

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

templating-engine

An alternative to ejs

latest
Source
npmnpm
Version
1.1.0
Version published
Maintainers
1
Created
Source

nodetmp

An alternative to ejs.

Installation

npm i nodetmp

Usage

import { compile } from "nodetmp";

const output = compile(pathOfInputFile, dataObje);

console.log(output.output); // compiled output

output.write(pathForOutput); // write file at given location

template

{:if condtion}
<!-- if body -->
{:else}
<!-- else body -->
{/if} 
{:each array as item,id}
<!-- body -->
{/each}

As middleware

import {html_renderer} from "nodetmp";

app.use(html_renderer);

then we can use "res.html" function to parse html file.

// first argument -> path of html file relative to root folder
// second argument -> data which need to be  passed 
app.get("/", (req, res) => res.html("/index.html", {count:0}))


// index.html

<h1> {count} </h1>

there is also a "include" function available to include another html file.

// counter.html

<h1> {count} </h1>


// index.html

// one argument -> path relative to root folder
<div> 
    {include("/counter.html")}
</div>

License

MIT

Keywords

templating engine

FAQs

Package last updated on 17 May 2022

Did you know?

Socket

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