Product Thumbnail

HMPL

Lightweight server-oriented template language for JavaScript

Open Source
Developer Tools
GitHub

HMPL.js provides the flexibility to build server-driven templates with minimal JavaScript. With its block-based syntax, customizable fetch requests, and built-in support for forms, events, and time-based syncing you can deliver dynamic user interfaces without relying on a heavy framework. HMPL integrates with JSON5 for expressive object syntax and DOMPurify for safe HTML rendering, all in just a few kilobytes.

Top comment

Congratulations on the launch @HMPL team!

And to Anthony, who's been working on HMPL.js for a loong time. 💖

Comment highlights

Hey Product Hunt! 👋

I, Anthony Max, am pleased to introduce a templating language that can reduce the size of your applications by a significant amount while maintaining the same interface.

I would also like to say a big thank you to @fmerian for the opportunity.

If you have ever worked with HTMX or Alpine.js, you may have noticed that these modules are quite limited. The idea behind them is brilliant, but the implementation is not extensible. With this template language, we tried to create something in between them and EJS or PUG.

👀 How this project can be useful for you

  • Create powerful HATEOAS applications with just one server integration module

  • A small application is not only a plus for less memory in GitHub or GitLab, but also a fast loading of the page by the customer of the build that weighs a couple of megabytes

  • Don't depend on the current DOM like in other modules, you can put the code in a separate file with the .hmpl extension and work there

⚙️ Features

  • Customizable: Send a custom request to the server when receiving the UI

  • Memory Preserving: Reduce file sizes on the client by several times

  • Generate thousands of DOM nodes from a single template: Work with large components not only on the server but also on the client

  • Protected from XSS attacks: Enable incoming server HTML sanitization with DOMPurify and work with it safely

📌 Examples of use:

👀 Why is this launch important to us?

We implemented the functionality together for almost a year. We found the right syntax by trial and error. Today we see that this really has serious practical application, which is why people's feedback is so important to us ❤️.

What do you think about this template language? It will be interesting to know your opinion 🌱!

Thank you all!

Really like the lightweight, server-driven approach. HMPL feels like a great middle ground between full frameworks and static templating. Curious how it scales for larger apps and real-time interactions!