zambal

zambal

Vaux - a framework agnostic, html aware templating library

Hi all,

I just published the first public release of Vaux, a component based and html aware templating library. Recently, I found myself looking for an Elixir templating library, because I wanted to experiment with htmx, a javascript library that I’m sure most here already know about. But for those who don’t, htmx in a nutshell extends html in such a way that it lets you add interactivity and partial page loads to a otherwise static web page. In some way, I think it tries to solve the same problem as Phoenix LiveView, but being purely a client side library, its approach is quite different.

I really like the concept of HEEx templates and Phoenix components, but I guess mostly because of my background that involves mostly dabbling with backend systems, working directly with a simple http server like Bandit or Cowboy has my preference. While I think you techically can just use function components and ignore all other stuff, including Phoenix LiveView in a project feels a bit heavy handed if all you need is html templating. So I thought there’s still some room to fill in the Elixir ecosystem and started building a framework agnostic, html aware templating library.

Originally, my main inspiration for Vaux was Vue templates, as I have used Vue through the years quite a lot and like its simple template syntax. However, I appreciate good editor integration with at least sensible coloring of syntax, so I eventually decided to borrow some syntax from HEEx and take advantage from it’s excellent editor support.

I guess the end result looks a lot like HEEx templates, mixed up with some Vue templating concepts and a couple ideas of my own. Just like HEEx templates,most work is being done at compile time, so I expect performance to be at least in the same order of magnitude. Great care has been taken to provide sensible warnings or errors with correct line number information at compile time in order to catch typos as soon as possible.

The library still needs some work, but should already be pretty usable in its current state. I think the most important functionality that is missing currently is some mechanic for allowing fallthrough attributes (vue lingo, I think this is managed in Phoenix with global attributes) and dealing with style and script elements. style and script elements are currently handled just like any other type of element, but the {...} interpolation syntax doesn’t work well in these contexts.

Hope some find this useful too and would love to have some feedback!

Most Liked

LostKobrakai

LostKobrakai

I’d suggest using a different sigil to heex. This will be picked up by the heex formatter, which will then complain that it cannot format the contents, so people won’t be able to use heex and vaux in the same project while using the formatter.

Where Next?

Popular in Libraries Top

pkrawat1
Hey guyz We at @aviabird are working on a payment library in elixir/phoenix. We are targeting March 2018 to add 56 Gateways to it. Have...
New
seancribbs
Today I released a new dialyzer Mix task as the dialyzex package! At the time we started writing this task, the existing dialyzer integra...
New
woylie
I released Doggo, a collection of unstyled Phoenix components. Features Unstyled Phoenix components. Storybook that can be added to...
New
dbern
I’m excited to announce that TaxJar has developed and open-sourced DateTimeParser. We developed it because we found a need to parse user ...
New
achempion
Hi, I would like to tell about my initiative to further maintain and develop Waffle project which is the fork of Arc library. The progre...
New
Qqwy
Solution is a library to help you with working with ok/error-tuples in case and with-expressions by exposing special matching macros, as ...
New
benlime
LiveMotion enables high performance animations declared on the server and run on the client. As a follow up to my previous thread A libr...
New
woylie
Flop is an Elixir library that applies filtering, ordering and pagination parameters to your Ecto queries. offset-based pagination with...
New
msaraiva
Surface is an experimental library built on top of Phoenix LiveView and its new LiveComponent API that aims to provide a more declarative...
564 42633 214
New
OvermindDL1
I created a new library (rather I pulled out a couple files from my big project), it manages an operating system PID file for the BEAM. ...
New

Other popular topics Top

jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod -- where is this set? Thanks.
New
fireproofsocks
I’m working on defining a simple Ecto schema for a table (in PostGres), but I don’t see where I can define a column as NOT NULL. Conside...
New
stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
danschultzer
None of the current solutions worked well for me, so I went ahead and built a user management system from scratch. This project took far...
548 27727 240
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
qwerescape
Is there a way to get the call stack or stack trace at any point in the code? Not from exceptions, but an expression that returns how the...
New
msaraiva
Surface is an experimental library built on top of Phoenix LiveView and its new LiveComponent API that aims to provide a more declarative...
564 42633 214
New
ovidiubadita
Hey all, I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
skosch
To my knowledge, put_in, Map.update etc. all have the one limitation of not automatically creating intermediate keys when needed (for exa...
New
AstonJ
We’ve put together this wiki for Phoenix LiveView - please feel free to add any info you feel is worth including. What is Phoenix LiveV...
New

Sub Categories:

We're in Beta

About us Mission Statement