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
28 stars 4 forks source link

Rename `as_ref` filter into `ref` #40

Closed GuillaumeGomez closed 6 days ago

GuillaumeGomez commented 1 week ago

It's not calling the AsRef trait and I'd prefer to clear any potential confusion and to follow the same nomenclature as deref.

Kijewski commented 6 days ago

I think it might be best to simply remove (as_)ref and deref, what do you think? In #39 you introduce the prefix operators * and &, and I like these operators much better than filter. Esp. since the filters are kinda magic: You couldn't implement the yourself when you write your own filters.

GuillaumeGomez commented 6 days ago

Unfortunately I think these two filters remain useful in filters chaining. For example if you have a filter to_u32 which expects a &str, then you need to do:

{{ "{{}}"|format(a)|ref|to_str }}

This example is easy to fix without these filters, but some more advanced might not. Allowing users to go around this limitation still seems pertinent to me.

Kijewski commented 6 days ago

Ah, yes, you're right. In a filter chain it is useful!