npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@mohsensami/template-engine

v1.1.0

Published

A simple template engine for Express.js

Downloads

27

Readme

@mohsensami/template-engine

npm version npm downloads license

A simple and lightweight template engine for Express.js using {{key}} syntax for dynamic templating. It’s easy to use, has no dependencies, and is perfect for quick and minimalistic projects.


Features

  • Simple Syntax: Use {{key}} to inject dynamic data into your templates.
  • Lightweight: No dependencies other than Node.js built-in modules.
  • Express Compatible: Fully supports Express.js’s app.engine for seamless integration.
  • Flexible: Works with any .tpl file in your views directory.

Installation

Install the package via npm:

npm install @mohsensami/template-engine

Usage

Setting Up in Express.js Here’s how to integrate @mohsensami/template-engine into your Express.js application:

  1. Import and Configure the Template Engine:
const express = require("express");
const path = require("path");
const templateEngine = require("@mohsensami/template-engine");

const app = express();

// Register the template engine with Express
app.engine("tpl", templateEngine.renderFile);
app.set("views", path.join(__dirname, "views"));
app.set("view engine", "tpl");
  1. Create a Template File: In the views directory, create a file named index.tpl:
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>{{title}}</title>
</head>
<body>
    <h1>{{message}}</h1>
</body>
</html>
  1. Render the Template: Define a route in your application and render the template with dynamic data:
app.get("/", (req, res) => {
    res.render("index", { title: "Welcome!", message: "This is a custom template engine!" });
});
  1. Run Your App: Start the server:
node app.js

Visit http://localhost:3000 in your browser to see your rendered template.

How It Works

The @mohsensami/template-engine uses the {{key}} syntax to dynamically replace placeholders in your .tpl files with values from the data object passed to res.render.

For example, given the template:

<h1>{{title}}</h1>
<p>{{description}}</p>

And the data object:

{ title: "Hello, World!", description: "This is a simple template engine." }

The rendered output will be:

html Copy code

<h1>Hello, World!</h1>
<p>This is a simple template engine.</p>

License

This project is licensed under the MIT License. See the LICENSE file for details.

Contributing

Contributions are welcome! Feel free to submit issues or pull requests to improve this package.

Author

Created by Mohsen Sami.

Links

GitHub Repository - https://github.com/mohsensami/template-engine npm Package - https://www.npmjs.com/package/@mohsensami/template-engine