-
-
Notifications
You must be signed in to change notification settings - Fork 156
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
update dom elements #2
Comments
@cj do you mean transform the HTML and returning the modified version as string? Can you show an example of usage? |
html = """
<div>
<span>hello</span>
</div>
"""
Floki.parse(html)
|> Floki.transform("span", fn element -> {"div", [], ["goodbye"]} end )
#
# <div>
# <div>goodbye</div>
# </div>
# Rather than just find the elements that match and return them as a list, it would use the original parsed HTML data structure as the accumulator and apply the callback function to replace each match. |
@brweber2 Thanks for the proposal. Yes, this is possible. I think for this feature we need something more flexible, like a "protocol" for saying that we want to "add" attributes, or change the tag name (type), or "push" a new child into the tree. Something like:
What do you think? |
Since there was not much discussion here I'm closing this issue. |
Is it possible to update the dom elements?
The text was updated successfully, but these errors were encountered: