Foolproof HTML
11–20 of 110 posts
Re: Foolproof HTML
#12I 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 I used emmet for a while but slim improves on writing and reading code.
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.
Re: Foolproof HTML
#13Re: Foolproof HTML
#14I 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 I used emmet for a while but slim improves on writing and reading code.
Re: Foolproof HTML
#15Problem with things like slim is that you cannot copy-paste directly from HTML.
Re: Foolproof HTML
#16Isn't this haml without templating?
Re: Foolproof HTML
#17Use S-expression syntax instead of SGML syntax, i.e. instead of:
content
write
((tag attr value ...) content)
and use Lisp to process it. It's actually quite straightforward. You can apply it to XML as well. Everything actually ends up looking a lot prettier this way.
See http://weitz.de/cl-who/ for an example of an implemented system that works this way. I've been using it in production for years. It works like a charm.
Re: Foolproof HTML
#18Re: Foolproof HTML
#19 '(html
(head
head stuff ...)
(body
(h1 "My HTML")
(div (@ class "main-div" ...)
"main div stuff")))
Of course it gets a lot more complicated when generating complete web pages and apps, but using paste operators, procedures and variables can make it produce anything necessary.A very similar approach is possible with Tcl, which I am using now for several reasons including integration with legacy code. In Tcl the above looks like:
{html
{head
head stuff ...}
{body
{h1 {! My HTML}}
{div {@ class "main-div" ...}
{! main div stuff}}}
In Tcl variables and procedures can be interpolated into the output by wrapping the list in a "subst" command: [subst {html .... [my-proc $my_var] ....}]
The hierarchical nature of Lisp-like languages naturally resembles the GUI outline form the author presents in the article. Using Tcl it's occurred to me that it should be possible to write a "front end" to the parser/generator code using Tk (via the text or canvas widgets) which could resemble the author's illustrations.Ultimately I think the difficulty lies in the need for constructing customized templates to enable modular, easy-to-use GUIs for particular tasks. Real HTML can quickly become very complex which is the reason for the thousands of frameworks, generators and templating systems in existence. While I think the author's approach or my own can potentially be helpful, neither is going to magically eliminate the burden on the programmer.
Re: Foolproof HTML
#20> If you have a good strategy for validating your template files, I'd love to hear it! Use S-expression syntax instead of SGML syntax, i.e. instead of: content write ((tag attr value ...) content) and use Lisp to process it. It's actually quite straightforward. You can apply it to XML as well. Everything actually ends up looking a lot prettier this way. See http://weitz.de/cl-who/ for an example of an implemented sys…