Skip to content

Support {% if ...; end; ... %} macro expressions#15917

Merged
straight-shoota merged 1 commit intocrystal-lang:masterfrom
HertzDevil:feature/macro-exp-after-if
Jun 25, 2025
Merged

Support {% if ...; end; ... %} macro expressions#15917
straight-shoota merged 1 commit intocrystal-lang:masterfrom
HertzDevil:feature/macro-exp-after-if

Conversation

@HertzDevil
Copy link
Contributor

@HertzDevil HertzDevil commented Jun 21, 2025

Follow-up to #14505. The following is already valid: (this is not a MacroIf node, but a MacroExpression node whose first sub-expression is an If, because the if is closed within the braces)

{%
  2 if 1
  3
%}

This PR adds support for the equivalent with a non-trailing if:

{%
  if 1
    2
  end
  3
%}

In fact, macro interpolation already transforms the former into the latter; these previously broken interpolations will now work.

{% unless ...; end; ... %} is also handled in the same way.

{{ ... }} expects a single expression and never an expression list in the first place, so that form is unaffected.

@HertzDevil HertzDevil changed the title Support {% if; ...; end; ... %} macro expressions Support {% if ...; end; ... %} macro expressions Jun 21, 2025
@straight-shoota straight-shoota added this to the 1.17.0 milestone Jun 23, 2025
@straight-shoota straight-shoota merged commit cb264e3 into crystal-lang:master Jun 25, 2025
41 checks passed
@HertzDevil HertzDevil deleted the feature/macro-exp-after-if branch June 25, 2025 09:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants