absolutejam

absolutejam

Alternate template engines

Hey,

I’ve been enjoying LiveView for an internal toy-project, but I’m looking to see if there are any alternative HTML rendering/templating engines.

I’ve found https://github.com/rstacruz/expug which would be ideal as pug is my go-to, but it hasn’t been updated in 2 years and has no LiveView support.

There is also https://github.com/slime-lang/slime but this looks like it has some outstanding major issues.

Anyone have any suggestions or ideas?

Regards.

First 10 of 16 Posts Switch mode

eahanson

eahanson

I’ve been using slime for 2+ years and it’s great!

It takes a few minutes to get used to it, but once you do, the thought of typing all the HTML boilerplate seems barbaric :slight_smile:

Slime:

table.extra-wide
  tr
    th colspan=2 Name
    th Age

  = for user <- @users do
    tr
      td= user.first_name
      td= user.last_name
      td= user.age

There’s even an eex to slime converter to get you started.

Edit: use phoenix_slime to use Slime with Phoenix.

absolutejam

absolutejam OP

Slime looks ideal but the LiveView is mentioned but not really documented anywhere, and the current implementation (which I couldn’t get to work) apparently doesn’t do incremental updates.

As great as the eex/leex implementations are, I just can’t bear writing raw html!

Tzelon

Tzelon

There is also Temple that is looking promising. I didn’t have the chance to use it yet, but I’m going to try it in my next project.
https://github.com/mhanberg/temple/blob/master/README.md

absolutejam

absolutejam OP

I forgot about Temple when I posted this but Temple was my first choice when I started looking. There is currently an issue by the maintainer about implementing Live View, but it looks like they’ve not had the resources. I’d love o use Temple as the implementation as that’s keeping it even closer to raw Elixir.

I’ve looked at the current LiveView engine source code and it’s way above my Elixir skill level :man_shrugging:

edjroot

edjroot

Hey, if you’re still interested in using Expug, you can take a look at my forked repos (expug, phoenix_expug).

Nothing major done so far, but I fixed this simple bug and added support for LiveView (but I’m honestly not sure if it’s the right way to do it).

I haven’t updated the docs or anything and I don’t really have many plans for it besides fixing future bugs, but I’ll gladly help if I can. Anyway, I’ve been using it for a while (admittedly for pretty simple stuff) and I’ve had no problems except for that one minor bug.

silverdr

silverdr

So how’s the current state of the alternative templating languages? Any new info? I wouldn’t want to drop slim(e) unless its something HAML-like in the worst case. Therefore Temple doesn’t really cut it, even if I do appreciate its elegance.

derek-zhou

derek-zhou

Surface. It is much more than a template engine though.

Werner

Werner

I had a look at expug and was a bit happy, because pug itself has “extends” and “block”, which would make sense for a plugin development for a CMS or Ecommerce system (like Twig for PHP and Django for Python).
Unfortunately this is not implemented in expug, too bad.
I’m still looking for a good solution for this, I like Temple very much, but at the moment I don’t know how to use it or also heex for a good plugin development.

naytro

naytro

What about liquex ?

Werner

Werner

Thanks for the advice. I haven’t used Liquid until now, but I don’t see in the docs of Liquid that you can overwrite a small part of a template in a plugin like you can in Twig or Django.
It’s always about the whole theme, which is of course strange. As I said, I may be mistaken.

Where Next?

Trending in Questions Top

stjefim
Hello! Suppose you are building workflow (order / task / payment) processing system with the following requirements: Each workflow con...
New
jonnycharles
I’m in search of an Elixir library that offers PDF generation capabilities similar to Ruby’s Prawn. While there have been discussions abo...
New
spammy
I’m looking to build a personal workflow to quickly deploy web applications written in elixir/phoenix, for local consumption (ie not on t...
New
silverdr
Using Phoenix.LiveView.TagEngine as an EEx.Engine is deprecated! To compile HEEx, use Phoenix.LiveView.TagEngine.compile/2 instead. Sta...
New
dli
Before I dive in myself, did anyone successfully sprinkle Hologram into their existing LiveView app? Looking for hints regarding: Addi...
New
bottlenecked
Hi all, I wanted to ask how the community is dealing with post-release steps. Today we have Ecto migrations, which make sure that the db...
New
michallepicki
I am using Oban and occasionally, shortly after a deployment, a handful of jobs can fail because of dependency on other parts of the syst...
New

Other Trending Topics Top

JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge &amp; Solve. They are GUI (Emerge) and State management (S...
New
ausimian
Emily is an Elixir library that runs Nx computations on Apple’s MLX. Install it as the default Nx backend and Nx, defn, Axon, Nx.Serving,...
New
type1fool
I just stumbled on a newly redesigned elixir-lang.org. :tada: It looks like @Software_Mansion did the work, and I think it is generally a...
New
juhalehtonen
There has been a thread to discuss the Stack Overflow Developer Survey on this forum every year since 2018, so here’s yet another one for...
New

We're in Beta

About us Mission Statement