stencilproject / Stencil

Stencil is a simple and powerful template language for Swift.
https://stencil.fuller.li
BSD 2-Clause "Simplified" License
2.35k stars 224 forks source link

Resolvable boolean expressions #164

Closed ilyapuchka closed 6 years ago

ilyapuchka commented 6 years ago

This PR adds ability to resolve boolean expressions the same way as variables like {{ this == that }}

This have a potential to simplify templates when there is a need to evaluate boolean expression and output its result, true or false, in a template, i.e. when generating html to enable or disable html elements. Instead of {% if this == that %}true{% else %}false{% endif %} it will be possible to write just {{ this == that }}

Also this PR adds support for parsing static boolean expressions, i.e. if {% if true %}. There was implementation for such expression and tests for it, but it was never actually parsed. It may not be very important, but can be helpful during template development.

djbe commented 6 years ago

Before I forget: This PR should document the changes in the docs.

ilyapuchka commented 6 years ago

@djbe @kylef comments addressed, can you look again?

djbe commented 6 years ago

@ilyapuchka why close this? The docs are there, it should be GTM.

ilyapuchka commented 6 years ago

there were conflicts and tests started to fail for some reason after I merged, I'll need to to investigate that but I also don't feel like this is a top priority considering other open PRs

djbe commented 6 years ago

Which tests? CI succeeds for the latest commit in this PR.

ilyapuchka commented 6 years ago

Only because I didn't push 😉