Premailex.HTMLInlineStyles (Premailex v1.0.0)

Copy Markdown View Source

Inlines CSS styles into a Premailex.html_tree/0.

Summary

Functions

Adds inline styles from CSS rules (t:CSSParser.rule/0) to a Premailex.html_tree/0.

Functions

process(tree, css_rules)

Adds inline styles from CSS rules (t:CSSParser.rule/0) to a Premailex.html_tree/0.

Examples

iex> tree = Premailex.parse(~s(<html><head><style>p{background-color: #fff;}</style></head><body><p style="color: #000;">Text</p></body></html>))
iex> css_rules = Premailex.CSSParser.parse("p{background-color: #fff;}")
iex> Premailex.HTMLInlineStyles.process(tree, css_rules)
[
  {"html", [],
  [
    {"head", [], [{"style", [], ["p{background-color: #fff;}"]}]},
    {"body", [], [{"p", [{"style", "background-color: #fff; color: #000;"}], ["Text"]}]}
  ]}
]