lambda-fairy / maud

:pencil: Compile-time HTML templates for Rust
https://maud.lambda.xyz
Apache License 2.0
2.14k stars 143 forks source link

prevent accidental misuse of if-else #449

Open untitaker opened 2 weeks ago

untitaker commented 2 weeks ago

i had this template in my code:

@if condition { path_a }
else { path_b }

maud rendered this to:

path_a
<else>path_b</else>

it would be nice if maud could make all of its own constructs reserved keywords, so that this situation doesn't occur anymore. there shouldn't be a reason to ever create an <else> tag. if there is, surely new syntax like "else" { .. } can satisfy that usecase.

puetzp commented 1 week ago

I regularly forget to add @ in front of maud keywords too, so I like the suggestion.

However I would propose to only merge a pull request that implements this if it does not come with a noticeable performance hit during compilation. I appreciate the fast compilation speed of maud templates immensely (the template engine I used prior to maud was an order of magnitude slower) and the smooth programming experience that comes with it.

That being said, I think I will take a stab at this when I find the time.

Edit:

It probably just needs to be added here.