Sha256: b5641047910921f7e52fd4935d20f545e26d051617b27b45b822538bebc8be66

Contents?: true

Size: 554 Bytes

Versions: 1

Compression:

Stored size: 554 Bytes

Contents

# A temple filter that handles escaping HTML unless it's been wrapped in
# an HTMLSafeString.
class Brut::FrontEnd::Templates::EscapableFilter < Temple::Filters::Escapable
  using Brut::FrontEnd::Templates::HTMLSafeString::Refinement

  def initialize(opts = {})
    opts[:escape_code] ||= "::Brut::FrontEnd::Templates::EscapableFilter.escape_html((%s))"
    super(opts)
  end

  def self.escape_html(html)
    if html.kind_of?(Brut::FrontEnd::Templates::HTMLSafeString)
      html.string
    else
      Temple::Utils.escape_html(html)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
brut-0.0.1 lib/brut/front_end/templates/escapable_filter.rb