Floki.find_and_update
You're seeing just the function
find_and_update
, go back to Floki module for more information.
Specs
find_and_update( html_tree(), css_selector(), ({String.t(), [html_attribute()]} -> {String.t(), [html_attribute()]} | :delete) ) :: html_tree()
Searches for elements inside the HTML tree and update those that matches the selector.
It will return the updated HTML tree.
This function works in a way similar to traverse_and_update
, but instead of updating
the children nodes, it will only updates the tag
and attributes
of the matching nodes.
If fun
returns :delete
, the HTML node will be removed from the tree.
Examples
iex> Floki.find_and_update([{"a", [{"href", "http://elixir-lang.com"}], ["Elixir"]}], "a", fn
iex> {"a", [{"href", href}]} ->
iex> {"a", [{"href", String.replace(href, "http://", "https://")}]}
iex> other ->
iex> other
iex> end)
[{"a", [{"href", "https://elixir-lang.com"}], ["Elixir"]}]