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 🙏

© 2024 – Pkg Stats / Ryan Hefner

jsts-node

v0.1.0

Published

Node helpers for JSTS files

Downloads

6

Readme

jsts-node

Helper functions for working with JSTS templates in Node

About

A set of helper functions for working with JSTS templates as files, processing, and outputting interpolated templates as other files.

By using JavaScript Template Strings for templating content in node you can make use of any variables JavaScript knows about, make use of JavaScript's built-in logic for templating any other language you're working with, and even write plugins and mixins that help you extend your templates all in 100% vanilla JavaScript.

Usage

This package is provided in CommonJS module format and is intended to be run in Node. You can download it here from Github, or grab a copy from npm:

Installing from npm

npm install jsts-node

Functions

Load

load(path)
  • path a path to one or more files which should be read as JSTS templates

Use load() to load the contents of files in your filesystem as JSTS templates. This function returns an array containing strings of file contents matching the path supplied to the function.

Process

process(files, environment)
  • files a string or array of strings containing JSTS templates to be interpolated
  • environment any object containing any objects you wish to be available to the template during interpolation

This function accepts an array of JSTS templates and any JavaScript objects you wish to be made available to your JSTS template during its interpolation and sends them to be processed by the jsts-engine package. The return from this function is the return from processing the templates with the jsts-engine package, an array containing the final interpolated template as well as an output object which isn't used by the other functions in this plugin.

Output

output(files, filename)
  • files a string or array of strings containing interpolated templates
  • filename a filename to write to

The output() function accepts strings to be written to a file, and a filename to write them to.

Compile

compile(path, filename, environment)

// equivalent to
output(process(load(filename), environment), path)
  • path a path to one or more files which should be read as JSTS templates
  • filename a filename to write to
  • environment any object containing any objects you wish to be available to the template during interpolation

This function is a load-process-output workflow expressed at a higher level, where you only supply the path of JSTS template(s) to be read, a filename to write the result to, and any JS objects you want available to the template(s) during interpolation.