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

jsht

v1.0.4

Published

Tool to generate templates, using node js.

Readme

jsht

Program to generate templates files using NodeJS code, using tags <# #> and <#= #> to print values. With all capabilities NodeJS has to offer.

Prerequisites

NodeJS installed.

Installing

npm i -g jsht

Getting Started

1 - Create new template: Template file will be created at current dir/.jshtTemplates/create/class.js

jsht -n create class

2 - Edit new template current dir/.jshtTemplates/create/class.js

<#
    //any NodeJS here
    var className = "HelloWorld";
#>

class <#=className#>{

}

3 - Execute template

jsht create class

Will generate



class HelloWorld{

}

Examples

Create new template file

jsht -n create class

New template file will be created at current dir/.jshtTemplates/create/class.js.

Execute template file

jsht create class

Execute template file: current dir/.jshtTemplates/create/class.js.

Hello World

<#
    //any NodeJS here
    var className = "HelloWorld";
#>

class <#=className#>{

}

Will generate



class HelloWorld{

}

Print text

print text: <#
    printText("printed text");
#>

short form: <#="printed text"#>

Will generate

print text: printed text

short form: printed text

IF

<#if(5 > 6){#>
    var biggerVar;
<#}else{#>
    var smallerVar;
<#}#>

Will generate


var smallerVar;

FOR

<#for(var i = 0; i < 10; i++){#>
   let var<#=i#>;
<#}#>

Will generate


   let var0;

   let var1;

   let var2;

   let var3;

   let var4;

   let var5;

   let var6;

   let var7;

   let var8;

   let var9;

Location variables

Outputfile: <#=outputFile#>
Outputfile directory: <#=currentDir#>
Template name: <#=templateName#>
Template path: <#=templatePath#>
Template path directory: <#=templateDir#>

Will generate

Outputfile: <YOUR_LOCATION>/class.js
Outputfile directory: <YOUR_LOCATION>
Template name: class
Template path: <YOUR_LOCATION>/.jshtTemplates/create/class.js
Template path directory: <YOUR_LOCATION>/.jshtTemplates/create

Change output Name

<#
    outputFile = "myNewFile.js";
#>

Change output location

<#
    outputFile = "../class.js";
#>

not generating output location

<#
    outputFile = "";
#>

or

<#
    outputFile = null;
#>

Overwite file without asking -rf option overwrite existing files without asking. Example

jsht create class -rf

Output generated template in console
-outputTemplate
Example

jsht create class -outputTemplate

Output generated JS Code in console for debug
-outputJSCode
Example

jsht create class -outputJSCode

Create global template A global template can executed in any folder/path. To creat global template instead local template add "-g" after "-n":

jsht -n -g create class

First jsht will look for the template at "./.jshtTemplates" folder, if not found it will look search in the global template path.

Global template path Get

jsht config template location

Set

jsht config template location C:/Desenv/Templates

Require Modules Install your modules at ".jshtTemplates" folder, to see where ".jshtTemplates" is, execute command "jsht config template location". Any module installed at your ".jshtTemplates" folder will be accessible by require method in your template.

Require Files A js file can be called using require, by the relative path of the template file. Example:

require("./folder/fileToBeCalled");

Call Template from template

callTemplate("./otherTemplate.js", [], []);

or through command:

execShell("jsht otherTemplate");

The second parameter is an array of input arguments. The third parameter is an arrays of named arguments.

Build in functions

  • execShell - execute command in the system
          params:
                command - command to be executed
                path - optional, folder to execute the command, if not provided it will be executed on the current folder.
    Example:
execShell("ls");
execShell("cd ..");

Input Args Aditional parameters will became arguments inside the template:

jsht create class MyClassName calculateAge
class <#=inputArgs[0]#>{
     <#=inputArgs[1]#>(){

	 }
}

Named Args Passing named parameters.

jsht create class -methodName calculateAge -className MyClassName
class <#=namedArgs["className"]#>{
     <#=namedArgs["methodName"]#>(){
		 
	 }
}