Live data from Hacker News

Hamlet: A type-safe Haml template engine for Go

github.com

31–40 of 42 posts

Re: Hamlet: A type-safe Haml template engine for Go

#31
post #29
post #26

Earlier quoted context omitted.

True, but almost no one is writing HTML anymore. So if I'm anyway post-processing my tsx / jsx / vue / whatever files, I might was well use a language that's great. As for adding a layer to what devs needs to learn - that's why I don't generally use this at work. In those situations you often need to pick the most common tools and not the best tools.

> almost no one is writing HTML anymore JSX?

That’s right, JSX is also not HTML.

Re: Hamlet: A type-safe Haml template engine for Go

#34

The example has left me with a strong impression I should avoid this and HAML. That syntax frightens me.

Had a lead dev who really liked HAML.

He was working on a web app and we deduced he hated HTML, because 1) he liked HAML, and 2) the two most technical people spent a lot of time cleaning up bugs he authored.

That whole project was a mess so that never achieved high priority status. I would have distrusted HAML anyway, but that experience certainly punctuated that feeling.

This is not an arena where an impedance mismatch has any payoff worth paying. You're working on a web app. Use HTML and CSS (SCSS if you must)

Re: Hamlet: A type-safe Haml template engine for Go

#35
post #24
post #20

Earlier quoted context omitted.

sure, I guess lighting the house with fire also works!

In my experience, adding a layer between you and what you are doing adds a potential layer to every bug, and a layer to what new developers need to learn. That needs a lot of justification.

One of these major “no closing tags” templating languages had been chosen for a Rails project I once onboarded to. I wanna say it was Slim, but it may have been another.

It was dog slow and it had some really stupid api you had to use if you needed to handle nesting that you couldn’t determine until runtime (on account of the no closing tags—use case: rendering a tree of data in a streaming-records sort of situation, not exactly a super-rare need).

There was a faster implementation, several times faster… but it achieved that in no small part by ditching the bits of the api that allowed you to manipulate nesting, so I couldn’t use it.

That project made me hate crap like this. HTML isn’t scary, hard, or even (in a halfway modern editor) slow to write, FFS. I’ll never ever pick this sort of templating language when it’s my choice.

Re: Hamlet: A type-safe Haml template engine for Go

#36
post #28

Earlier quoted context omitted.

Because JSX is just document.createElement() with syntax sugar. If Haml has an equivalent api, there should be a way to implement something similar.

I don't understand, I thought document.createElement() is independent of JSX. JSX works just as well in Deno/Bun/Node.js without DOM functions.

[deleted]

Re: Hamlet: A type-safe Haml template engine for Go

#37
post #28

Earlier quoted context omitted.

Because JSX is just document.createElement() with syntax sugar. If Haml has an equivalent api, there should be a way to implement something similar.

I don't understand, I thought document.createElement() is independent of JSX. JSX works just as well in Deno/Bun/Node.js without DOM functions.

I haven't looked into the details about how server side rendering is done. It should have something equivalent to generate HTML. But the point still stands, it should be possible to follow the same pattern to create a JSXesque template for HAML

Re: Hamlet: A type-safe Haml template engine for Go

#39
post #6

That's great; Haml is one thing I like most when doing web development on Ruby/Rails. The only thing I don't like about this implementation is the blocks with inline code: - if user != nil { %strong The user exists - }

This is something I would like to have working, the subtraction of the braces that is. I did have a naive solution where it would insert the braces for you if the left the opening brace off and it would assume you wanted the closing brace too. This caused problems when I would put in a continuation of an if statement like:

    - else if other_condition
      %span other content
    - else
      %span another bit of content
I pulled the broken solution completely and do plan to revisit dropping the brace requirement because not having the braces aligns with the idea/reason why you'd use Haml in the first place.

Re: Hamlet: A type-safe Haml template engine for Go

#40
post #6

That's great; Haml is one thing I like most when doing web development on Ruby/Rails. The only thing I don't like about this implementation is the blocks with inline code: - if user != nil { %strong The user exists - }

I use Haml in my web framework, I use syntax_suggest [1] to count the missing pairs so I can insert them automatically at the end of the block. It would probably not be too difficult to do the same thing in Go. 1. https://github.com/ruby/syntax_suggest/blob/main/lib/syntax_...

Thank you for posting this link. I'll check this out and see if I can get the braces dropped.
Post reply on HN