module

Marten::SEO::Escaping

HTML and JSON escaping for safe template rendering. Delegates to the shared web-escape shard (WebEscape), which provides byte-identical semantics to the original inline implementation (matching ERB::Util.json_escape semantics).

Instance methods

escape_html(text : String) : String

Escapes a plain-text string for safe embedding in HTML attribute values and text content. Crystal stdlib equivalent of Ruby's CGI.escapeHTML. Delegates to WebEscape.escape_html.

escape_json(json : String) : String

Escapes a JSON string for safe embedding inside a element. Replaces the five chars that can break out of or corrupt the script context. Delegates to WebEscape.escape_json.