Allow attribute values to not be escaped #422
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Oi @philss
Thanks for your hard work on Floki, it's a great package, we use it in production and it works really well!
I found a small issue when using the
raw_html
function with theencode: false
option.On the app I'm working on, we allow users to configure html blocks programatically using the liquid language. We allow them to use liquid in the content of an HTML tag as well as on the attribute values.
This means that users can end up configuring an element that will look like the following in Floki:
The issue I'm seeing happens when we try to convert elements like the one above into HTML using
Floki.raw_html(encode: false)
. It was my expectation that attribute values wouldn't be encoded/escaped when theencode
option was set as false.As the code stands today, Floki always escapes the values of the attributes.
This PR attempts a very raw implementation of not encoding/escaping the attribute values if the
encode
option is set tofalse
. So on the example above, the>
character always get converted to>
, which is not the behavior we are aiming for.I'm very much open to update this implementation in anyway you see fit in order to support a way in which attribute values are left as is.
Again, thanks for taking the time to maintain Floki, and looking forward to your response with guidance on how to proceed with this.
Cheers!