Skip to content

Commit

Permalink
Improve example of Floki.attribute/3
Browse files Browse the repository at this point in the history
Closes #501
  • Loading branch information
philss committed Dec 18, 2023
1 parent fd49dd6 commit 3fe2bc3
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions lib/floki.ex
Original file line number Diff line number Diff line change
Expand Up @@ -631,11 +631,19 @@ defmodule Floki do
iex> Floki.attribute([{"a", [{"href", "https://google.com"}], ["Google"]}], "a", "href")
["https://google.com"]
iex> Floki.attribute([{"a", [{"class", "foo"}, {"href", "https://google.com"}], ["Google"]}], "a", "class")
iex> Floki.attribute(
iex> [{"a", [{"class", "foo"}, {"href", "https://google.com"}], ["Google"]}],
iex> "a",
iex> "class"
iex> )
["foo"]
iex> Floki.attribute([{"a", [{"href", "https://google.com"}, {"data-name", "google"}], ["Google"]}], "a[data-name]", "data-name")
["google"]
iex> Floki.attribute(
iex> [{"a", [{"href", "https://e.corp.com"}, {"data-name", "e.corp"}], ["E.Corp"]}],
iex> "a[data-name]",
iex> "data-name"
iex> )
["e.corp"]
"""

@spec attribute(binary | html_tree | html_node, binary, binary) :: list
Expand Down

0 comments on commit 3fe2bc3

Please sign in to comment.