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

hmpl-js

v2.1.8

Published

Server-oriented customizable templating for JavaScript

Downloads

500

Readme

npm-version minzipped size codecov issues x.com

Usage

import hmpl from "hmpl-js";

const templateFn = hmpl.compile(
  `<div>
      <button data-action="increment" id="btn">Click!</button>
      <div>Clicks: {{ "src": "/api/clicks", "after": "click:#btn" }}</div>
  </div>`
);

const clicker = templateFn(({ request: { event } }) => ({
  body: event.target.getAttribute("data-action"),
})).response;

document.querySelector("#app").append(clicker);

Why HMPL?

Using HMPL, you can multiply reduce the size of the application bundle. Full customization of the request based on the modern fetch standard, as well as support for all the functionality necessary for modern work in applications (request indicator, sending by event, automatic generation of body for the form, caching) and the syntax of the object in the markup, which requires a minimum number of characters, will help to build interaction with the server and client as efficiently as possible.

Features

  • Customizable: Send a custom request to the server when receiving the UI
  • Memory Preserving: Reduce file sizes on the client by several times
  • Based on Fetch API: Use a modern standard instead of XMLHTTPRequest
  • Server-oriented: Work with the server directly through markup and with a little js
  • Generate thousands of DOM nodes from a single template: Work with large components not only on the server but also on the client
  • Simple: Get ready-made UI from the server by writing a couple of lines of familiar object syntax
  • Flexible: Can be used in almost any project due to not only working through a script, but also working in files with the .hmpl extension
  • No dependencies: Can connect from one js file
  • Small bundle size: Lots of functionality in a couple of kilobytes

Installation

hmpl can be installed in several ways, which are described in this article. This tool is a simple javascript file that is connected in the usual way through a script, or using the import construct in an environment that supports this (webpack build, parcel build etc.). The first and easiest way is to install using a CDN.

Package Manager

This method involves downloading through npm or other package managers.

npm i hmpl-js

Node.js is required for npm.

Along the path node-modules/hmpl/dist you can find two files that contain a regular js file and a minified one.

Manual download

You can install the package by simply downloading it as a file and moving it to the project folder.

<script src="./hmpl.min.js"></script>

If, for some reason, you do not need the minified file, then you can download the full file from this link.

<script src="./hmpl.js"></script>

The non-minified file is larger in size, but it is there as it is with all the formatting.

CDN

This method involves connecting the file through a third-party resource, which provides the ability to obtain a javascript file from npm via a link.

<script src="https://unpkg.com/hmpl-js/dist/hmpl.min.js"></script>
<!--
  integrity="sha384-..."
  crossorigin="anonymous"
-->

This resource could be unpkg, skypack or other resources. The examples include unpkg simply because it is one of the most popular and its url by characters is not so long.

Ecosystem

Community support

The documentation contains main information on how the HMPL template language works. If you have any questions about how HMPL works, you can use the following resources:

  • Github - In the discussion and issues sections you can ask any question you are interested in.
  • 𝕏 (Twitter) - There is a lot of interesting stuff there, concerning the template language and not only :)

You can also ask your question on Stack Overflow and address it in the resources described above.

Contribution

We have a Contributing Guide that describes the main steps for contributing to the project.

Thank you to all the people who have already contributed to HMPL, or related projects!

Fossa status

FOSSA Status