Class: LexxyVariables::Renderers::Substitution
- Inherits:
-
Object
- Object
- LexxyVariables::Renderers::Substitution
- Defined in:
- lib/lexxy_variables/renderers/substitution.rb
Overview
Default renderer. Replaces nonce placeholders with resolved values by plain string substitution. There is no template engine, so author-typed text can never be interpreted as code. Each value is HTML-escaped, so it is inert and cannot reintroduce markup the sanitizer already stripped.
assigns is a Hash of key => value. Values are coerced to escaped strings.
Instance Method Summary collapse
Instance Method Details
#render(html, nonce:, assigns:) ⇒ Object
10 11 12 |
# File 'lib/lexxy_variables/renderers/substitution.rb', line 10 def render(html, nonce:, assigns:) html.gsub(Placeholder.pattern(nonce)) { ERB::Util.html_escape(assigns[$1].to_s) } end |