Get the latest tech news
Show HN: HMPL β Small Template Language for Rendering UI from Server to Client
π Server-oriented customizable templating for JavaScript. Alternative to HTMX and Alpine.js. - hmpl-language/hmpl
In this example, we create a dynamic clicker component in which, when a button is pressed, we will receive the value of the current clicks that will come from the server. 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. 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 Protected from XSS attacks: Enable incoming server HTML sanitization with DOMPurify and work with it safely 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 Integrated with JSON5: Flexible writing of objects by docs as in vanilla js, as well as the reliability of the parser used by millions of people Small bundle size: Lots of functionality in a couple of kilobytes
Or read this on Hacker News