Liquid like macro html templating


#1

Hi,

One of the things I really like about rust is the idea of macros doing the work at compile type instead of having to parse and handle errors at runtime (i.e. println!).

Looking through the template libraries though, there appears to be two camps.

  1. The liquid based ones where html templates can be maintained by designers, but are parsed and error checked at runtime, and
  2. those that are parsed and checked during compilation, yet one has to write the pages using a custom syntax.

Is anyone working on html macro templating for some input that might have come from a web designer?
Would anyone else be interested in a library that does this? Anyone want to work on this?

Thanks.


#2

Yeah, I’ve thought about this a bunch of times, and did some investigation of serde_codegen and things like that. It looks like it’s not trivial to implement, and getting it working well on stable Rust seems even more challenging. So I have decided to hold off for now.

Basically, my thought was building something like Jinja/Twig, which compiles to Rust in a build.rs script, so that you get type safety. You want to define an input context struct for each template, I think, which is then expanded to have an impl based on the actual template contents.