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

tophatjs

v0.1.1

Published

a compile-time template engine

Readme

Overview

Why?

Tophat is a compile-time templating engine. The problem it attempts to solve is the slow and often ugly way other templating engines do run-time template processing. On the other hand, without a templating engine, trying to maintain the same html code in 100 different files is a nightmare. Tophat falls in the middle of these two options; it is a utility that does template processing not at run time, but before-hand, before the html files are pushed to a server. You could consider it a compilation step of sorts.

Usage

Html

Tophat makes use of a couple custom html5 data attributes. They are data-th-template and data-th-attr.

If you have a partial file that needs to be included into your html, add a div and point to the partial with the data-th-template attribute.

<div data-th-template="header.th"></div>

The engine also supports doing attribute replacement. In your partial, first prefix your attributes to be replaced with @.

<header>
  <h1>@header</h1>
  <p>@first-p</p>
</header>

Then in your html use the data-th-attr attribute in the same div as the template definition to give it values. It uses the same syntax as inline css.

<div data-th-template="header.th" data-th-attr="header:hello; first-p: hi, there;"></div>

The properties will be replaced on the next run.

<header>
  <h1>hello</h1>
  <p>hi, there</p>
</header>

Node

Tophat relies on and is run via node. To use it, run the following command.

node tophat.js

Tophat will look for all html files in the current directory, scan them for the data attributes above, and include the referenced partials' contents into the file.

That's all there is to it.