Re:Hamlet: A type-safe Haml template engine for Go
by ceritium on Tuesday January 02, 2024 @04:38AM
(#38839820)
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:
[ Parent
| on HN ]
Re:Hamlet: A type-safe Haml template engine for Go
by quechimba on Tuesday January 02, 2024 @07:24AM
(#38840897)
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
by stackus on Tuesday January 02, 2024 @08:28PM
(#38849574)
Thank you for posting this link. I'll check this out and see if I can get the braces dropped.
Re:Hamlet: A type-safe Haml template engine for Go
by leipert on Tuesday January 02, 2024 @05:27AM
(#38840149)
Couldn’t you do without the angular brackets?
- if user != nil
%strong The user exists
(That being said, the indentation bit also tripped me up in the past)
Re:Hamlet: A type-safe Haml template engine for Go
by stackus on Tuesday January 02, 2024 @08:26PM
(#38849565)
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.