4 ms·
I found my foolproof HTML in slim-lang. It produces standards-compliant HTML and prevents me from writing code that is not well-formed. The above is a nice si
by andrei_says_ 10y ago
I found my foolproof HTML in slim-lang.
It produces standards-compliant HTML and prevents me from writing code that is not well-formed.
The above is a nice side effect of its incredibly clean and terse syntax.
Now I feel cheated any time I need to write regular HTML.
https://github.com/slim-template/slim/blob/master/README.md https://github.com/slim-template/slim/blob/master/README.md
I used emmet for a while but slim improves on writing and reading code.
- ungzd 10y agoSlim becomes painful when using Ruby function calls (i.e. Rails helpers). Sometimes these functions have long list of parameters and wrapping to next line sometimes becomes not so convenient. Moving, copying and pasting indented blocks is also quite painful and it's much harder to see nested structure than in, for example, Python code. Also it has complicated syntax for attributes and text content, especially text content. I have to look up its docs again and again. It reminds me of yaml which has the same problems (but much worse, yaml's documentation has size of a book). However I'm not a fan of ERB or Django/Jinja template markups either. Indentation-based syntax has its advantages, it works well for Python and ML-like languages. Just Slim can be improved further.
- andrei_says_ 10y agoWould you consider pasting a sample? I do work with rails and can't think of a time when I have experienced this issue. Maybe when passing multiple cars to a partial?
- icebraining 10y agoSeems similar to HTML generation libs in Lisp, except with indentation instead of parenthesis.
- TylerE 10y agoYes, and here at least, I think indentation is a BIG win over parenthesis.
- pg314 10y agoI disagree. When you want to move a block of code around, it makes it too easy to make mistakes. Or if you want to add e.g. a div around a bunch of other elements, you need to be very careful with the indentation. I've worked with both: s-expression based syntax and whitespace-sensitive syntax. I'll take s-expression based syntax any time. Have you used both?
- TylerE 10y agoYes, extensively. In any half-way modern editor indentation-aware copy and paste/block indent/dedent is super easy.
- pg314 10y ago> In any half-way modern editor indentation-aware copy and paste/block indent/dedent is super easy. Sure. But I've made mistakes in Python because I didn't select e.g. the last line of a region. If you've used both extensively and prefer whitespace to sexps, that's totally valid. De gustibus non est disputandum.