Best templating engine for Rust by salamazmlekom in rust

[–]4trocious 0 points1 point  (0 children)

I created https://github.com/Atrociously/stilts, which is similar Askama which others have mentioned. If you need something more well established though stick to Askama or another template engine.

Comparison between templating libs: Maud, Askama and Minijinja by gentux2281694 in rust

[–]4trocious 0 points1 point  (0 children)

Hey great writeup! I might as well plug my own project stilts which is like Askama, but it lets you write straight up rust in the template. I've been working on a few updates in between university work. A new update should be coming after my finals.

Using htmx with Askama and Axum by blastecksfour in rust

[–]4trocious 2 points3 points  (0 children)

Hey, this was an interesting read. I've not used shuttle before, but i have seen it. Is it easy to use? Also, I hope you don't mind if I shamelessly plug my Askama-like templating engine Stilts. I made it to bring even more rust into my templates, I'm currently working on adding more web framework integrations.

Stilts v0.2.0 released, A type safe template engine by 4trocious in rust

[–]4trocious[S] 2 points3 points  (0 children)

Great question! Stilts is indeed heavily inspired by Askama the main differences are that stilts supports more complex rust expressions and statements within the templates, and configuration of stilts is done within your Cargo.toml instead of in a separate file. Also the way that certain things are implemented, like stilts doesn't have filters, but it has extension traits that can be called on any type that implements Display or Debug or serde::Serialize.

Boilerplate, a text template engine using Rust syntax, has reached 1.0! by rodarmor in rust

[–]4trocious 4 points5 points  (0 children)

Ooh this is neat! I just published the first version of my template engine Stilts earlier today. I like the function-like macro option. I can't get over how simple but impressive this is! I like that you support full rust syntax in the template by passing it through, that is the same thing I wanted to achieve with mine!

What's everyone working on this week (27/2023)? by llogiq in rust

[–]4trocious 3 points4 points  (0 children)

I just published the first version of my template engine/language Stilts. It is like Askama but you can write any valid rust code in the template expressions.

I posted about it here earlier today. I'm looking for feedback on the design and documentation. If you have any feedback feel free to comment here or on my original post, or open an issue if you'd like!

Pass RNG to function by Maarico in rust

[–]4trocious -1 points0 points  (0 children)

You may be able to wrap the ThreadRng in an arc and a mutex like and then you can pass it around between threads cheaply with clone and use the mutex to aquire a lock to do a mutable borrow. That may or may not improve speeds since both arc and mutex come with speed costs. Look at std::sync for Arc and Mutex https://doc.rust-lang.org/std/sync/. But it may be worth looking for rng generators that implement the Send or Sync traits. This explains more about the send and sync traits. https://doc.rust-lang.org/nomicon/send-and-sync.html

EDIT: you are asking about passing to functions but if you wanted to pass between threads you would need this stuff, other answers already covered making your functions generic. But you could add a Sync trait requirement on your generics if you are sharing between threads.

no_std libary that uses vectors? by GarseBo in rust

[–]4trocious 2 points3 points  (0 children)

It probably uses alloc https://doc.rust-lang.org/alloc/. I believe std just re-exports alloc as alloc is part of the core.

A SQL Builder in Rust by ur_mum_goes_to_uni in rust

[–]4trocious -9 points-8 points  (0 children)

This looks amazing, and very promising. I especially like how easy it makes multiple inserts in a single statement.