diff --git a/spec/instance_template/if_spec.cr b/spec/instance_template/if_spec.cr index dbe4f24..74db2a1 100644 --- a/spec/instance_template/if_spec.cr +++ b/spec/instance_template/if_spec.cr @@ -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 diff --git a/src/instance_template.cr b/src/instance_template.cr index 65cd51f..5b7104e 100644 --- a/src/instance_template.cr +++ b/src/instance_template.cr @@ -82,7 +82,7 @@ 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 @@ -90,7 +90,7 @@ module ToHtml {{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}}