CrowdHailer / eex_html

Extension to Embedded Elixir (EEx), that allows content to be safely embedded into HTML.
https://hex.pm/packages/eex_html
Apache License 2.0
3 stars 5 forks source link

if condition needs an else clause or it will crash #3

Closed Nicd closed 5 years ago

Nicd commented 6 years ago

If you use an if structure, you need to add an else clause, or nil will be added to the output, which will crash when the content is attempted to convert to string.

For example here, the empty else clause is required, to return an empty string instead of nil:

<%= raw(if ... do %>
  <%= ... %>
<% else %>
<% end) %>
CrowdHailer commented 6 years ago

Can you write a test case.

If it's possible to do a small one add it as a doc test here https://github.com/CrowdHailer/eex_html/blob/master/lib/eex_html/engine.ex#L26

Be good to have several test cases.

If the PR is open with desired behaviour in tests it's really easy for someone to pick it up

Nicd commented 5 years ago

This no longer occurs on the latest version for some reason so I'm closing this issue.

CrowdHailer commented 5 years ago

well thats handy :+1