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

Supporting transforms for Floki nodes! #65

Closed
bobjflong opened this issue Sep 2, 2016 · 1 comment · Fixed by #66
Closed

Supporting transforms for Floki nodes! #65

bobjflong opened this issue Sep 2, 2016 · 1 comment · Fixed by #66

Comments

@bobjflong
Copy link
Contributor

Hi! Thanks so much for Floki!

I have a need to transform Floki nodes. For example, to turn all relative links into absolute links:

html = "<p><a href='/foo'>click!</a></p>"
Floki.transform(html, "a", fn({"a", [href: x], xs}) -> {"a", URI.merge("https://base.com", x), xs} end)
# => [{"p", [], [{"a", [{"href", "https://base.com/foo"}], ["click!"]}]}]

Instead of requiring the implementation of a recursive search, do you think there is space in the Floki API for a transform function like above? I'd be up for cutting a PR myself. Just wondering if you have any thoughts.

@philss
Copy link
Owner

philss commented Sep 4, 2016

Hi @bobjflong! Thank you for the PR and the issue! 😃 I couldn't check this with attention yet, but I will check soon. :)

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 a pull request may close this issue.

2 participants