August 9th, 2024

HMPL – template language for displaying UI from server to client

hmpl is a lightweight server-side template language that generates HTML, reducing JavaScript size and improving loading speeds for SPAs. It supports loading indicators, error handling, and offers various installation options.

Read original articleLink Icon
HMPL – template language for displaying UI from server to client

hmpl is a lightweight template language designed for generating HTML on the server side, which is then sent to the client. This method reduces the size of JavaScript files and enhances loading speeds for single-page applications (SPAs). Key features of hmpl include the use of the Fetch API for server requests, minimized client-side JavaScript by generating markup on the server, and built-in support for loading indicators and error handling within templates. Installation can be done via npm, manual download, or through a CDN. A basic usage example demonstrates how to compile a template and append the generated HTML to a specified DOM element. Additional resources such as the official website, documentation, demo sandbox, and examples repository are available for users. The hmpl language is licensed under the MIT License.

- hmpl is a server-side template language that generates HTML for client use.

- It reduces client-side JavaScript requirements, improving SPA loading speeds.

- Installation options include npm, manual download, and CDN usage.

- The language supports loading indicators and error handling in templates.

- Comprehensive resources and documentation are provided for users.

Related

Htmx does not play well with content security policy

Htmx does not play well with content security policy

HTMX, a JavaScript framework, presents security challenges due to its handling of HTML tags and external script loading. Despite some security features, HTMX usage raises HTML injection risks, complicating full security implementation.

Templating in JavaScript, from Zero Dependencies on Up (2021)

Templating in JavaScript, from Zero Dependencies on Up (2021)

The article explores dependency-free templating in JavaScript, favoring template literals and functions over traditional methods like JSX. It demonstrates creating components with functions and suggests a small dependency for enhanced syntax. Benefits include simplicity and flexibility for rendering in diverse environments.

Show HN: Gothem stack – An Htmx and templ template

Show HN: Gothem stack – An Htmx and templ template

The "gothem-stack" GitHub project is a flexible template using Go, Templ, HTMX, Echo, and Mage. It supports TailwindCSS, DaisyUI, and Alpine.js, aiding quick setup and various functionalities. Persistence relies on Postgres and sqlc.

FastHTML – Modern web applications in pure Python

FastHTML – Modern web applications in pure Python

FastHTML is a Python library for building web applications efficiently, supporting dynamic content, reusable components, and various databases. It simplifies development, focusing on performance and scalability for Python developers.

From React to Htmx on a real-world SaaS product (2022) [video]

From React to Htmx on a real-world SaaS product (2022) [video]

David Guillo shares his experience replacing React with htmx in a SAS product, highlighting htmx's advantages for creating rich user interfaces without JavaScript frameworks, emphasizing accessibility and ease of use.

Link Icon 11 comments
By @echoangle - 5 months
Maybe I’m misunderstanding this but I find it crazy that people now act like generating HTML server side is a genius new idea that is going to replace JS Frameworks. Isn’t that kind of the default and the SPA Frameworks were the new idea? Imagine telling a PHP dev that you’re now rendering your HTML server side! I’m happy to be corrected if I’m wrong here but it’s very weird from my view.
By @Dansvidania - 5 months
can someone smarter than me please point out what the differences are between HMPL and HTMX?
By @zelcon - 5 months
Ah sweet finally I don't have to use JavaScript to make websites

*looks inside, it's JavaScript*

By @randomgiy3142 - 5 months
Isn’t this what rpc/pbs/code-gen theoretically does? Markup/down sent? Then you don’t have to worry about the client or server language but settle on a subset of features somewhere.

My flow is that focusing on the data structure and methods allows the UI to be completely abstract. Not in a magic way but in a “maybe we should use cross compile this into C++ and use OpenGL if the UI becomes too complex. This is how you get AutoCad or film editing software running essentially as a Proton/video game runs.

When your app gets beyond a certain level of complexity (window composition, etc) yeah there’s ways to make it happen.

By @antonmak1 - 4 months
Regarding the standards that should be applied to template languages - all this will be adjusted as it develops. This module comes as a new idea that I would like to implement into a really good product. Even when working on Cample, I thought about something similar.
By @gessha - 5 months
I’m currently learning frontend (vanilla JS and bootstrap) and client-side render the UI for some of my ideas.

From my understanding, modern frameworks(React) use both. Why would you limit yourself to just server-side? Isn’t there a trade off between server-side and client-side rendering?

By @evbogue - 4 months
By @antonmak1 - 4 months
Thank you very much to everyone for your feedback on the template language!
By @antonmak1 - 4 months
Big thanks to thunderbong for making this thread. I just noticed it, sorry.
By @allanren - 5 months
So it's sort like Jinja?