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
124 stars 9 forks source link

Add support for macro argument default value #198

Open GuillaumeGomez opened 1 week ago

GuillaumeGomez commented 1 week ago

It's possible in jinja to have default value for macro arguments:

{% macro input(name, value='', type='text', size=20) -%}
    <input type="{{ type }}" name="{{ name }}" value="{{value|e }}" size="{{ size }}">
{%- endmacro %}
Kijewski commented 1 week ago

Should be easy enough to implement. What kind of default values would you allow? Only literals?

GuillaumeGomez commented 1 week ago

For a first step I think it's enough. We can always add function calls or constructors later on.

Please leave this one to me. :p

Kijewski commented 1 week ago

Please leave this one to me. :p

Hehe, I will. Have fun with it! :D

GuillaumeGomez commented 1 week ago

Thanks! :D