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

lwte

v0.2.2

Published

This is a simple, fast, lightweight template engine.

Downloads

10

Readme

LWTE.js

This is the Light Weight Template Engine for JavaScript.

Description

Example

Template:

<p>{text}</p>
{if table}
<table>
    {if table-head}
    <thead>
    <tr>
        {each table-head}
            <th>{name}</th>
        {/each}
    </tr>
    </thead>
    {/if}
    <tbody>
    {each table-body}
        <tr>
        {each datas}
            <td>{}</td>
        {/each}
        </tr>
    {/each}
    </tbody>
</table>
{/if}

Data:

{
    "text" : "This is an example.",
    "table" : true,
    "table-body" : [
        {datas : ["1", "2"]},
        {datas : ["3", "4"]}
    ]
}

Result:

<p>This is an example.</p>
<table>
    <tbody>
        <tr>
            <td>1</td>
            <td>2</td>
        </tr>
        <tr>
            <td>3</td>
            <td>4</td>
        </tr>
    </tbody>
</table>

That's almost all!

How to write templates

Briefly, just write {VAR_NAME}.
But there are 11 reserved keywords.
if, elif, else, /if, each, /each, switch, case, default, /switch, use, html
You can't use them as variable name even if they contain capital letters.

Syntax

DATA is a data which is given to lwte.useTemplate.

  • {}
    Displays DATA with html-escape.
  • {VAR_NAME}
    Displays DATA[VAR_NAME] with html-escape.
  • {if VAR_NAME ...}{elif VAR_NAME ...}{else}{/if}
    You can use this just like general if-elif-else-statement.
    Controlling expressions will be treated as true if all variables are evaluated as true.
  • {each VAR_NAME}{/each}
    You can use this just like general foreach-statement.
  • {switch VAR_NAME}{case VALUE ...}{default}{/switch}
    You can use this just like general switch-statement.
    But switch-statement of LWTE.js doesn't do fall through.
    Case-statements which has the value of the variable will be executed.
  • {use TEMPLATE_NAME VAR_NAME}
    You can use this just like lwte.useTemplate(TEMPLATE_NAME, DATA[VAR_NAME]).
  • {html VAR_NAME}
    Displays DATA[VAR_NAME] without html-escape.

Evaluating variable

false : false, undefined, null, [], and {}
true : all other

Requirement

This is a stand-alone JavaScript library.

Usage

Do npm install lwte or
clone this repository.
And require lwte.js.

var lwte = new LWTE(); //create LWTE instance
lwte.addTemplate("TEMPLATE_NAME", "TEMPLATE"); //add templates
var result = lwte.useTemplate("TEMPLATE_NAME", DATA); //use templates
//also you can save compiled templates

License

License

Author

ryo33