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

template-text

v0.2.1

Published

text from template for all purposes

Readme

template-text

generate text from template for all purposes with LiveScript syntax. Use eval so one should always use this with owned/reviewed template.file.

Note: this is equivalent to run code in template. Always use it with trusted data source only.

Usage

install with npm:

npm install --save template-text

command name and parameters:

tt -c config.file -o output.file template.file

You can also require a module as config to use functions in the template from the module:

tt -r some-module -o output.file template.file

API

Programmatically interpolate your template with template-text api:

tt = require("template-text")
cfg = function() { return { ... }; } || { ... };
ret = tt("<template-file-content>", cfg, <root-path>);

where:

  • cfg: a hash of all available variable
  • root-path: reference root when look up files for include api.

Template File Format

For every string you want to replace, use !{ ... } with variable / expression inside. For example,

Hello !{user.name}!

You have visited our website for !{user.count} time.

It also supports conditional block:

!{if user.count > 10 => '''

it seems that you have been here for many times.

''' else '''

Newcomer here? You probably will want to take a look at our tutorial.

'''}

If you need interpolation inside expressions, please note that """ is escaped so you need to use !"" ... ""!:

!{if user.count > 10 => !""

it seems that you have been here for !{count} times.

""! else !""

Hi !{name}, newcomer here? You probably will want to take a look at our tutorial.

""!}

When calling with API, you can even use builtin functions for expressions, or custom function if you pass it into the config object:

A random number: !{Math.random()}
A random UUID: !{uuid()}

Program counterpart for above text:

uuid = require("uuid");
tt = require("template-text");

ret = tt(<the above text>, {uuid: uuid});

Again, we use LiveScript to parse the expression when interpolating, so it's quite dangerous to load template from untrusted source. Be sure to only use template-text with templates from trusted source.

Builtin Functions

Except common JS APIs, you can also use following API in template:

  • include(filename) - recursively include file in place.

TODO

  • Token Customizing - It's possible that the token !{ ... } is used by the target language / syntax of the text we want to interpolate. So it will be nice if we can make it customizable.
  • Defaul Language - make it customizable about the language users want to use, at least for following languages:
    • ES6 ( ES2015 or later )
    • TypeScript

License

MIT