Phlex.SGML.Attributes (phlex v0.3.0)

Copy Markdown View Source

Attribute generation and escaping for Phlex components.

Handles attribute name normalization, value escaping, and security validation aligned with Phlex Ruby 2.4.1.

Summary

Functions

Decodes HTML character references used to obfuscate javascript: URLs.

Generates HTML attributes from a keyword list or map.

Functions

decode_html_character_references(value)

Decodes HTML character references used to obfuscate javascript: URLs.

generate_attributes(attributes, buffer \\ "")

Generates HTML attributes from a keyword list or map.

Examples

iex> Phlex.SGML.Attributes.generate_attributes([class: "foo", id: "bar"])
" class=\"foo\" id=\"bar\""

iex> Phlex.SGML.Attributes.generate_attributes([disabled: true])
" disabled"

iex> Phlex.SGML.Attributes.generate_attributes([style: [color: "red", padding: "10px"]])
" style=\"color: red; padding: 10px;\""