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

logi-tpl

v0.0.1

Published

JS template engine for Node.js. Along with the classic template features, it supports subtemplates inclusion, asynchronous fragments and direct function calls.

Readme

logi-tpl

A standalone template engine with support for asynchronous content.

About

logi-tpl is a simple but powerful templating system. The way it works is very close to the way PHP is used as a template engine. Full JavaScript functionality can be used inside the templates. See below for more details.

Features

  • No other language should be learned. JavaScript is the template language.
  • Subtemplates can be included. Different parameters can be passed to them.
  • Async content can be inserted wherever needed.

Installation

Installing npm (node package manager)

Installing logi-tpl

Usage

The template engine may work in several convenient ways. The simplest one is this:

var logiTpl = require ('../logi-tpl');
	
logiTpl.applyToFileTemplate (__dirname + '/template.html', {	
	name : 'John Dow',
	age : 21
}, function (error, result) {
    if (error) {
	    console.log ('Error: ', error);			
	} else {
		console.log (result);
    }
});

template.html

Your name is <%= name %>.
<% if (age > 18) { %>
    You are allowed to proceed.
<% } else { %>
    Sorry, you are not allowed to proceed.
<% } %> 

Output:

Your name is John Dow.
You are allowed to proceed.

Instead of providing a file resource, you can directly pass the template as a string and call

logiTpl.applyToStringTemplate (templateCode, params, function (error, generatedContent) {
    /* ... */
}, templateRoot);

If you need to compile a template for a later use, you can do it easily:

logiTpl.compileTemplateCode (templateCode, function (error, compilationResult) {
    /* ... */
}); 

Then use:

logiTpl.applyToCompiledTemplate (compiledScript, params, function (error, generatedContent) {
    /* ... */
}, templateRoot);

The last argument 'templateRoot' can be used when subtemplates are included. When applyToFileTemplate is used, the templateRoot is automatically exctracted from the template file name.

Basic template syntax

In general, if no <% ... %> sections are present, the content is directly returned as it is. The content inside <% and %> pairs is executed as a standard JavaScript. Syntax like the one below is fully valid:

<% if (a > 1) { %>
    some text
<% } %> 

Additionally, content inside <%= and %> is "printed" to the output. There is one special case - if the expression inside <%= ... %> is a function, then this function is expected to provide a content asyncronously. The engine invokes it with a callback parameter and the function should invoke this "callback" with the content passed as an argument. Check example2.js for more details.

Subtemplates are included by using:

<%~ "sub/template.html" %>   

By default, all the parameters are passed to the subtemplate. If you need to pass different parameter set, you can use:

<%~ "sub/template.html", { a : 3, b : 4 } %>   

Planned features

The following things are planned for future releases:

  • Improved parsing
  • Better parse error details
  • Custom compiler options
  • New tag pairs like <%& %> for HTML escape and several more.
  • Other :)