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

tuplates

v0.4.0

Published

Tale as old as time. I started developing a new static site for [patchbay.pub](https://patchbay.pub/). At first it was just a single page. But of course eventually I needed to add a header. And of course HTML doesn't have a way to [include another HTML fi

Downloads

1

Readme

Introduction

Tale as old as time. I started developing a new static site for patchbay.pub. At first it was just a single page. But of course eventually I needed to add a header. And of course HTML doesn't have a way to include another HTML file, because why would that be useful?

tuplates is a simple way to template your static sites, without creating a dependency on your templating tool. Rather than replacing your template tags, it works by replacing lines between your template tags. This means that both your template and code live together in your files. When you need to make a change, you update the fragment and re-run tuplates, and it replaces the old code. This way you can check your actual code into source control, rather than your templates.

The name comes from "update templates".

Installation

npm install -g tuplates

Usage

Create a tuplates directory containing your fragments as files. You can name them whatever you want.

project_directory/
  index.html
  index.js
  tuplates/
    header.html
    footer.html
    data.txt

Insert tuplate tags as comments in your code:

<!-- index.html -->
<!doctype html>
<html>
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <title>tuplates</title>

  </head>

  <body>
    <!-- tuplate_start(header.html) -->
    <!-- tuplate_end() -->

    <main>
      <h1>My Awesome Content</h1>
    </main>

    <!-- tuplate_start(footer.html) -->
    <!-- tuplate_end() -->
  </body>

</html>
// index.js
console.log("Hi there");

// tuplate_start(data.js)
// tuplate_end()

console.log(data);

Run the tuplates command in the directory above the tuplates directory. It will walk the directory and replace the lines between the tags with the tuplates.

After running once, the source files look like this:

<!-- index.html -->
<!doctype html>
<html>
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <title>tuplates</title>

  </head>

  <body>
    <!-- tuplate_start(header.html) -->
    <!-- tuplates/header.html -->
    <div class='header'>
      <h1>My Awesome Header</h1>
    </div>
    
    
    <!-- tuplate_end() -->

    <main>
      <h1>My Awesome Content</h1>
    </main>

    <!-- tuplate_start(footer.html) -->
    <!-- tuplates/footer.html -->
    <div class='footer'>
      <h1>Awesome Footer</h1>
    </div>
    
    <!-- tuplate_end() -->
  </body>

</html>
// index.js
console.log("Hi there");

// tuplate_start(data.js)
// tuplates/data.js
const data = {
  a: 1,
  b: 2,
  c: 3,
};

// tuplate_end()

console.log(data);

If you re-run it again, the result is the same, even though there's already code between the tuplate tags. It simply replaces whatever is in there (if there is anything).

Note that this README was partially generated with tuplates (see the Markdown tuplates in this project's tuplates directory). Unfortunately it takes some manual intervention to work, in part because tuplates doesn't currently support nesting.