rinja-rs / rinja

A template rendering engine based on Jinja, generating type-safe Rust code at compile time.
https://rinja.readthedocs.io
Apache License 2.0
116 stars 10 forks source link

Favor methods over closure fields #37

Closed GuillaumeGomez closed 3 months ago

GuillaumeGomez commented 3 months ago

Very surprisingly, we can't call methods directly, however closures (which are fields) can be called. I don't think this incentive makes sense as methods are much more common than closures as fields. Also, it now follows the rust syntax way.

GuillaumeGomez commented 3 months ago

Hopefully, not too many fixes like this should follow, still working on switching docs.rs from tera. :3

Kijewski commented 3 months ago

To call a function in the current scope, you have to call {{ self::function(args) }} then, don't you? Maybe you could add a test to ensure this syntax works, and maybe mention it in the book?

GuillaumeGomez commented 3 months ago

Should be the same as the current situation but having more tests is always a good idea!

GuillaumeGomez commented 3 months ago

Added test and updated docs (which were not mentioning functions surprisingly).