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

Don't generate part of templates if we "know" (ie, we have literal's value) that it will never be entered #47

Open GuillaumeGomez opened 4 days ago

GuillaumeGomez commented 4 days ago

For example:

{% set x = true %}

{% if x %}
bla
{% else %}
blo
{% endif %}

In this case, we know for absolutely sure that it'll never enter the else block, so we could completely remove the condition.

Same could be done with other literals (like string).