Today's vibe is to talk about the new version of the template language. We've been working on this project for a year and a half now, and, man, this is definitely the level of seriousness we're looking for.
You might think that after all this time, things could be done much better. That's true, but the fact is, what we have is really, really cool.
Let's take a look at the new version and see what we've prepared :)
π Bind
Articles usually fill you with unnecessary fluff, whether on topic or not. I like to do that too, of course, but let's get straight to the most important thing.
<div class="{{requestStatus}} class1">Text</div>
{{#request
src="/api/getHTML"
bind="{{requestStatus}}"
}}{{/request}}
result:
<div class="hmpl-status-requestStatus-200 class1">Text</div>
Yes, now instead of indicators you can write custom classes and other attributes in general.
It's worth noting that the functionality itself is unique in that I took the code from Cample, a previous project that is one of the fastest on the internet. Working on it has finally helped me, as this speed will now also transfer to the template language implementation :)
π How is it with HATEOAS?
One of the key goals of a template language is to conveniently create applications on a HATEOAS architecture. That is, when we receive routes from our API that we can use to interact with the page.
{
"id": 10,
"name": "Lenovo Laptop",
"price": 899.99,
"inStock": true,
"_links": {
"self": { "href": "/products/10" },
"add_to_cart": { "href": "/cart", "method": "POST" },
"category": { "href": "/categories/laptops" },
"related": { "href": "/products?relatedTo=10" },
"reviews": { "href": "/products/10/reviews" }
}
}
In this application paradigm, we understand that future versions of the template language will be aimed at convenient interaction with the server in this format. Because when we work in a regular application, we have to know all these routes, whereas here we simply describe the component, and then the necessary API routes are returned to us.
Repo: https://github.com/hmpl-language/hmpl
Full list of changes: https://hmpl-lang.dev/changelog


Top comments (2)
New version be like:

Real