For LiveView until Phx 1.6 there were .eex
and .leex
templates, both using “eex” as templating language. Now there’s .heex
, which works both with “Live” and “Dead” views. While there’s no problem using e. g. http://slime-lang.com/ with dead templates, there’s an unclosed issue regarding “Support for Phoenix 1.6 & HEEx”. Is this kind of “HEEx” support a requirement? Or? Does anyone have first-hand experience with non-dot-heex (compatible) templates for LiveView in Phx 1.6+ ?
Another templating language can be implemented, but it’s not trivial. See the mentions about Phoenix.LiveView.Rendered
in the Phoenix.LiveView.Engine docs
. So someone would have to write an implementation for Slime that returns those structs (unless they went the custom EEx engine way).
Here’s a silly little DSL I wrote for LiveView that I recall actually worked. It was a challenge to try to get it working without using any macros, that’s why the result looks very interesting (awful):
(On the other hand I kind of liked that EEx DSL – the first file in the snippet – and would use it if I didn’t have live views. :D)
I’m wondering how tricky it would be to transform other templating languages to a heex template. So one wouldn’t need to own the complete template → rendered struct code, but only the template → heex (template) transformation.
I think that’s the way slime-lang for Phoenix works already. At least for .eex
. Haven’t checked under the hood though.
mhanberg/temple: An HTML DSL for Elixir and Phoenix (github.com) is a very interesting alternative to heex. It supports LiveView as well as regular eex templating - but - with pure elixir code.