ModestEx v0.0.7-dev ModestEx
This module exposes features to do pipeable transformations on html strings with CSS selectors, e.g. find(), prepend(), append(), replace() etc.
Credits:
The package implements bindings to Alexander Borisov’s Modest. The binding is implemented as a C-Node based on the excellent example of Lukas Rieder’s cnodex and myhtmlex.
Example
iex> ModestEx.find(“
Hello World
”, “p a”) [“Hello”]Link to this section Summary
Functions
Append new html as a child at the end of selected node. Returns updated html string
Find nodes with a CSS selector. Returns the outer html of each node as a list of strings
Get all attributes with key. Returns list of strings
Get all text. Returns list of strings
Insert new html after selected node. Returns updated html string
Insert new html before selected node. Returns updated html string
Prepend new html as a child at the beginning of selected node. Returns updated html string
Remove nodes with a CSS selector. Returns updated html string
Replace selected node with new html Returns updated html string
Serialize any string with valid or broken html. Returns valid html string
Set value for all attributes with key. Returns single html string or returns list of strings
Set text for all nodes. Returns single html string or returns list of strings
Link to this section Types
Link to this section Functions
Append new html as a child at the end of selected node. Returns updated html string
Examples
iex> ModestEx.append(“
Hello
World
”) “Hello
World
Find nodes with a CSS selector. Returns the outer html of each node as a list of strings.
Examples
iex> ModestEx.find(“
Hello World
”, “p a”) [“Hello”]iex> ModestEx.find(“
Hello World
”, “span”) [“Hello”, “World”]Get all attributes with key. Returns list of strings.
Examples
iex> ModestEx.get_attribute(“Hello”, “href”) [“https://elixir-lang.org”]
Get all text. Returns list of strings.
Examples
iex> ModestEx.get_text(“
Insert new html after selected node. Returns updated html string
Examples
iex> ModestEx.insert_after(“
Hello
World
”) “Hello
World
Insert new html before selected node. Returns updated html string
Examples
iex> ModestEx.insert_before(“
World
Hello
”) “Hello
World
Prepend new html as a child at the beginning of selected node. Returns updated html string
Examples
iex> ModestEx.prepend(“
World
Hello
”) “Hello
World
Remove nodes with a CSS selector. Returns updated html string
Examples
iex> ModestEx.remove(“
Hello
WorldReplace selected node with new html Returns updated html string
Examples
iex> ModestEx.replace(“
Hello
World
”) “World
Serialize any string with valid or broken html. Returns valid html string.
Examples
iex> ModestEx.serialize(“
Set value for all attributes with key. Returns single html string or returns list of strings.
Examples
iex> ModestEx.set_attribute(“Hello”, “href”, “https://elixir-lang.org”) “
Hello”Set text for all nodes. Returns single html string or returns list of strings.
Examples
iex> ModestEx.set_text(“
Hello World