Module: LlmCostTracker::InlineStyleHelper
- Included in:
- ApplicationHelper
- Defined in:
- app/helpers/llm_cost_tracker/inline_style_helper.rb
Constant Summary collapse
- UNSAFE_CSS_CHARS =
/[<>{}"]/
Instance Method Summary collapse
Instance Method Details
#inline_style(declarations) ⇒ Object
7 8 9 10 11 12 |
# File 'app/helpers/llm_cost_tracker/inline_style_helper.rb', line 7 def inline_style(declarations) registry = inline_style_registry token = "lct-i-#{registry.length}" registry << [token, declarations.to_s.gsub(UNSAFE_CSS_CHARS, "")] token end |
#inline_style_block ⇒ Object
14 15 16 17 18 19 20 |
# File 'app/helpers/llm_cost_tracker/inline_style_helper.rb', line 14 def inline_style_block registry = inline_style_registry return "".html_safe if registry.empty? rules = registry.map { |token, decl| %([data-lct-style="#{token}"]{#{decl}}) }.join("\n") content_tag(:style, rules.html_safe, nonce: dashboard_csp_nonce) end |