Skip to content

Commit

Permalink
HTML-33 Fix nested if evaluation
Browse files Browse the repository at this point in the history
  • Loading branch information
sbsoftware committed Mar 10, 2024
1 parent 23860da commit 14468ad
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
7 changes: 6 additions & 1 deletion spec/instance_template/if_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@ module ToHtml::InstanceTemplate::IfSpec

ToHtml.instance_template do
if switch
p { "Hooray!" }
# nested ifs should work, too
if !!switch
if true && switch
p { "Hooray!" }
end
end
end
div do
if switch
Expand Down
4 changes: 2 additions & 2 deletions src/instance_template.cr
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,15 @@ module ToHtml
end
{% elsif blk.body.is_a?(If) %}
if {{blk.body.cond}}
{% if blk.body.then %}
{% if !blk.body.then.nil? %}
ToHtml.to_html_eval_exps({{io}}, {{indent_level}}) do
{{blk.body.then}}
end
{% if flag?(:to_html_pretty) && break_line %}
{{io}} << "\n"
{% end %}
{% end %}
{% if blk.body.else %}
{% if !blk.body.else.nil? %}
else
ToHtml.to_html_eval_exps({{io}}, {{indent_level}}) do
{{blk.body.else}}
Expand Down

0 comments on commit 14468ad

Please sign in to comment.