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

stejs

v1.0.1

Published

`npm install --save stejs`

Readme

STEJS - Simple Template Engine for JavaScript

npm install --save stejs

There is a webpack loader for this: stejs-loader.

You feed it a template, a context object with variables you want to access in your template and you get a processed file. Simple as that.

Usage

const fs = require('fs');
const stejs = require('stejs');

const inputStr = fs.readFileSync(__dirname + '/input.txt').toString();
const context = {
    myVar: 'hello!',
    myList: ['simple', 'template', 'engine']
}

const output = stejs(inputStr, context);
console.log(output);

input.txt:

$myVar$

$for item of myList$
$item$
$efor$

$for i in myList$
$i$ -> $myList[i]$
$efor$

$if myVar == 'henlo'$
hi!
$fi$

Output:

hello!


simple

template

engine



0 -> simple

1 -> template

2 -> engine



Syntax

STEJS tags are limited by two $, everything in between that is processed by STEJS. Depending on the structure of the content in the tag it will have a different behavior.

Expressions

Expressions in STEJS are evaluated and the result is converted to a string and pasted in the place of the tag.

Template:

<span>$post.publishDate$</span>
<span>$post.getAuthor().name$</span>
<span>$5 + 2$</span>

Context:

{
    post: {
        publishDate: '2020-06-24',
        getAuthor() { /*Some code and stuff */},
    }
}

Output:

<span>2020-06-24</span>
<span>ItsaMeTuni</span>
<span>7</span>

For loops

If the content of the tag matches a for loop it will repeat everything between it and a $efor$ tag. You can use either for of loops or for in loops. While loops are not supported yet.

Template:

<div>
    $for el of ['some', 'text', 'here']$
    <p></p>
    $efor$
</div>

Output:

<div>
    <p>some</p>
    <p>text</p>
    <p>here</p>
</div>

If statements

If the content of the tag matches the structure of an if statement everything between it and its $fi$ ending tag will only be rendered in the output if the result of the expression in the if statement is true.

Template:

$if 1 + 2 == 3$
<input type="button" />
$fi$

Output:

<input type="button" />

Parentheses are not needed. Else and else if statements are not supported yet.

Includes

Includes are a simple way of, well, including templates in other templates. When the template engine is run the include tags are just replaced with the contents of the included template. The context of the included template is the same context of the include tag that included it.

To include a template just $include('path')$.

Template:

<div class="content">
    Some content here blah blah blah
</div>
$include('src/footer.html')$

src/footer.html:

<div class="footer">
    Some footer info
</div>

Output:

<div class="content">
    Some content here blah blah blah
</div>
<div class="footer">
    Some footer info
</div>

The path is relative to where STEJS is running.

Template files

STEJS templates can have any file extension, as long as they are plain text files.