7 ms·
Enlive and related libraries for Clojure, Lift for Scala, and heist for Haskell use node transformation. I know that there are a few others I'm forgetting. Basi
by xaritas 11y ago
Enlive and related libraries for Clojure, Lift for Scala, and heist for Haskell use node transformation. I know that there are a few others I'm forgetting. Basically given a fragment of an HTML 5 or XML document, your view functions transform it into a different fragment. E.g. in Lift, given
<div class="greeting-container" data-lift="SayHello"><span class="greeting">lorem ipsum</span></div>
And a transformation:
".greeting *" #> "Hello World"
The output will be:
<div class="greeting-container"><span class="greeting">Hello World</span></div>
See http://exploring.liftweb.net/master/index-5.html#entry-CSS-Transforms-0 http://exploring.liftweb.net/master/index-5.html#entry-CSS-T... et alia
With this technique, your designers can create pure HTML and assets, with no logic in the templates. Basically they create static mock-ups and then the developers "enliven" them.
I prefer this but I don't imagine it will ever become mainstream.
React's JSX is also (as far as I can tell) node based, but with a lot less power (you can really only do insert operations, and the operations don't really compose well).
- tootie 11y agoI recently did a project using this type of template system and it was ok, but not really better than string-based templating. You're really still doing String-based templating except you're embedding all your directives in data attributes and it gets super messy and unreadable.