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

hamlet-plugin-template

v1.0.0

Published

A plugin template for hamlet

Readme

hamlet-plugin-template

Base template for creating Hamlet plugins.

Usage

  1. Rename the package in package.json (e.g. @scope/hamlet-feature or hamlet-plugin-feature).
  2. Implement your plugin in index.js.
  3. Run the tests.
  4. Publish to npm.

End-user installation

npm install hamlet-plugin-template
// hamlet.config.js
import myPlugin from 'hamlet-plugin-template'

export default {
  plugins: [
    myPlugin(),
    // or with options:
    myPlugin({ myOption: true }),
  ],
}

Plugins are imported and invoked directly from hamlet.config.js, similar to Vite or Rollup plugins. Hamlet never resolves plugins by package name—it only consumes the object returned by the plugin factory.

Plugin contract

A plugin must export a default factory function that receives the user's options and returns an object with the following shape:

export default function hamletPlugin(options = {}) {
  return {
    namespace: 'MyPlugin',
    partials: {},
    helpers: {},
  }
}

namespace

Every plugin must define a unique namespace.

  • It must start with a letter.
  • It may contain only letters and digits.
  • It is used to namespace all exported partials and helpers, preventing collisions with other plugins and the user's own project.

partials

An object containing Handlebars partials.

Every partial name must be prefixed with <namespace>..

Example:

export default function hamletPlugin(options = {}) {
  return {
    namespace: 'MyPlugin',
    partials: {
      'MyPlugin.card': '<div>...</div>',
    }
  }
}

helpers

An object containing Handlebars helpers.

Every helper name must be prefixed with the namespace followed by an uppercase letter.

Example:

export default function hamletPlugin(options = {}) {
  return {
    namespace: 'MyPlugin',
    helpers: {
      MyPluginFormat: value => value.toUpperCase(),
    }
  }
}

Helper names cannot contain dots because Handlebars interprets them as property paths rather than helper names.

Name collisions

Hamlet follows a first registered wins policy.

If a plugin attempts to register a partial or helper whose name already exists (whether provided by Hamlet, another plugin, or the user's project), the duplicate is ignored and a warning is printed.

Using Hamlet features inside plugin partials

Plugin partials can freely use Hamlet's built-in helpers and partials.

For example:

{{concat "Hello, " name}}

{{#switch value}}
  ...
{{/switch}}

{{> hamlet.snippet}}

Tests

Before publishing:

npm install
npm test

The test suite verifies that:

  • The plugin exports a valid factory function.
  • The returned object follows Hamlet's plugin contract.
  • A valid namespace is exported.
  • Partial and helper names follow Hamlet's naming rules.
  • Exported names use the plugin namespace.
  • No exported name collides with Hamlet's reserved names.
  • Partials compile successfully.
  • Helpers are valid functions.

Feel free to extend the tests with plugin-specific behavior or option validation.

Linting

This template uses the same ESLint configuration as Hamlet itself.

npm run lint
npm run lint:fix