Live data from Hacker News

Hamlet: A type-safe Haml template engine for Go

github.com

21–30 of 42 posts

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

#22
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_...

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

#24
post #20

Earlier quoted context omitted.

Why invent a new language so you don't have to close tags? Do I miss something?

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.

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

#25
post #12

Choosing hmlt as an identifier and file extension is pretty funny and feasibly a troll. Maybe hlet or hamlt would have been more obviously not html.

HMLT... does that stand for Haml Markup Language Template?

Just Hamlet disemvowelled I think.

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

#26
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.

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.

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

#27
post #3

I appreciate that in JSX, functions can be used as if they were first-class elements. In this case that would be accomplished by supporting the following instead: @hmlt HomePage() { %SiteLayout %p This is the home page for Hamlet. } Which is much cleaner IMO.

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

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

#28
post #3

I appreciate that in JSX, functions can be used as if they were first-class elements. In this case that would be accomplished by supporting the following instead: @hmlt HomePage() { %SiteLayout %p This is the home page for Hamlet. } Which is much cleaner IMO.

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.

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

#29
post #26
post #24

Earlier quoted context omitted.

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.

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?

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

#30
post #8

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

It looks unnecessary. The syntax is ugly and by looking at the examples I can’t say what problem it is supposed to solve.

> I can't say what problem it is supposed to solve

"Haml accelerates and simplifies template creation" https://haml.info/

If you'd rather write raw HTML, keeping track of closing tags etc, then don't use HAML. No need to bash it because you personally feel it is ugly or unnecessary. FWIW I personally feel the exact opposite.

Post reply on HN