https://htmx.org logo
Minijinja doesn’t make assumptions on how a given ...
# rust-htmx
i
Minijinja doesn’t make assumptions on how a given object gets processed when manipulating in a template. Say you pass context!(book => Book::default()) and a Book struct has a .title property and a .get_summary() method. Then if you do {{ book.title }} or {{ book.get_summary() }} in the template, the first will print nothing, and the second will result in “unknown operation”. Minijinja requires implementing the Object trait and then StructObject where we implement methods that explicitly say “if the property is .title, then return book.title.to_string()”, or “if calling a method called get_summary, then return book.get_summary()”, and so on. At least, I didn’t see anything like automating this in the docs. I must say, I think I’m definitely missing something. Maybe this should be handled by serde, which Minijinja leverages like other engines it seems (Tera, handlebars), but I haven’t dived into it just yet…