Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix HTML comment in raw_html #34

Merged
merged 2 commits into from Oct 9, 2015
Merged

Fix HTML comment in raw_html #34

merged 2 commits into from Oct 9, 2015

Conversation

glaucocustodio
Copy link
Contributor

Node tree with comments was crashing before this fix.

@@ -95,6 +95,7 @@ defmodule Floki do
defp raw_html([], html), do: html
defp raw_html(tuple, html) when is_tuple(tuple), do: raw_html([tuple], html)
defp raw_html([value|tail], html) when is_binary(value), do: raw_html(tail, html <> value)
defp raw_html([{elem, value}|tail], html) when elem == :comment, do: raw_html(tail, html <> "<!--#{value}-->")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@glaucocustodio here you don't need to use a guard. Instead, you can pattern match the elem:

defp raw_html([{:comment, value}|tail], html), do: raw_html(tail, html <> "<!--#{value}-->")

@glaucocustodio
Copy link
Contributor Author

Oh man, sorry, I am not too used to pattern match. I've fixed.

philss added a commit that referenced this pull request Oct 9, 2015
@philss philss merged commit b0bbb34 into philss:master Oct 9, 2015
@philss
Copy link
Owner

philss commented Oct 9, 2015

@glaucocustodio no worries 👍

@philss
Copy link
Owner

philss commented Oct 12, 2015

@glaucocustodio Released in the version 0.6.1 :)

@glaucocustodio
Copy link
Contributor Author

😸

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants