Top
Best
New

Posted by transpute 6 days ago

Liquid-rust: Liquid templating for Rust(github.com)
19 points | 12 comments
epage 12 hours ago|
Huh, of all of my projects, I never expected this to make it to HN. Not the original author but the maintainer, so ask away.

Unfortunately, I've not had as much time to devote to this for a while. There are also a lot of weird cases that aren't too well defined or that the Ruby implementation shines through that also have me dissatisfied with Liquid. That and wanting to make it easier to extend with an embedded language. A way to solve this and my annoyance is to create a template language using an existing embedded language. I'm tempted by koto because it already has something like `|` operator (`->`) and isn't just "Rust, but embeddable" (Rust is an implementation detail; it shouldn't bleed through).

[0] https://koto.dev/

hkalbasi 13 hours ago||
I like https://github.com/rust-sailfish/sailfish more. It accepts arbitrary Rust code in the template so you don't need to learn another syntax.
transpute 13 hours ago||
For ~100K authors with content on Github Pages, Liquid conformance avoids learning new template syntax or a programming language.

For a greenfield site where Jekyll/Liquid compatibility is not beneficial, Zola may be an option, https://github.com/getzola/zola

skrebbel 12 hours ago|||
One key feature of Liquid is that you can safely run customer-written code on your servers without worrying about security. It's a very underpowered language by design. This means that it's rather easy to be confident that its sandbox isn't leaky.
epage 12 hours ago||
Looks like this does compile time templating. There are reasons to explore using those over runtime templating but they don't cover all of the use cases.
transpute 13 hours ago||

  Conformant: Incompatibilities with strict shopify/liquid are bugs to be fixed.
  Flexible: Liquid embraces variants for different domains and we want to follow in that spirit.
  Performant: Do the best we can within what is conformant.
This has potential to replace Github Pages ruby-based Jekyll+Liquid, which is unusably slow on iOS without JIT.

Compiled cobalt with liquid-rust on iSH is fast enough for static blog publishing and browser-based offline site preview on iOS/iPadOS, https://news.ycombinator.com/item?id=46220227

tigranbs 12 hours ago||
Ah nice! I should integrate this into https://github.com/SaynaAI/sayna

``` Performant. Do the best we can within what is conformant. ```

Would be great to have benchmarks like ops/second

nesarkvechnep 13 hours ago||
I thought it is something like Liquid Haskell...
zokier 12 hours ago|
That would be LiquidRust without the hyphen https://publikationen.bibliothek.kit.edu/1000152005

or flux https://dl.acm.org/doi/10.1145/3591283

Blackarea 12 hours ago||
Why they call pipes filter? And if... endif? Not for me
epage 12 hours ago|
This is a Rust port of the Ruby implementation which was popularized by Jekyll, so it just does whatever was done in the Ruby implementation.

For an overview of liquid itself, see https://shopify.github.io/liquid/

toprerules 12 hours ago|
Ah, I thought this was adding refinement types to Rust based on Liquid Haskell. Disappointed.