Im migrating from rails, and expected this to work, in my template?
<% if true do %>
<li><p>hello</p></li>
<% else %>
<li><p>world</p></li>
<% end %>
None of the condition seem to get rendered. How to acheive this?
Thank you
You need to use <%=
instead of <%
<%= if true do %>
...
<% end %>
From the EEx docs:
All expressions that output something to the template must use the equals sign (=). Since everything in Elixir is an expression, there are no exceptions for this rule. For example, while some template languages would special-case if clauses, they are treated the same in EEx and also require = in order to have their result printed:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With