djc / askama

Type-safe, compiled Jinja-like templates for Rust
Apache License 2.0
3.25k stars 213 forks source link

Add support for remaining pattern syntax (..) in templates #1073

Open damymetzke opened 3 weeks ago

damymetzke commented 3 weeks ago

I do not believe there is a syntax available in the template syntax to pattern match on remaining values, like how you can do with structs in regular Rust:

MyStruct { foo, bar, ... } = my_struct

This would help in situations with large structs that are reused in multiple templates. One situation I'm dealing with now is that I send the same session context variable to all my templates, where each of them need just a few of the values. Right now, I need to update all templates if I add any new values to the session context.

I would be interested in writing a patch for this, however I can't find the time right now. I'm planning to pick this up myself later if it hasn't been done already.