Sha256: 7ce7020c5822fe23e466dd4594b66851a3ea6c83a9d52d34fc189a2e6fe4a970

Contents?: true

Size: 841 Bytes

Versions: 30

Compression:

Stored size: 841 Bytes

Contents

# frozen_string_literal: true
require 'haml/escapable'

module Haml
  # This module allows Temple::Filter to dispatch :fescape on `#compile`.
  module FescapeDispathcer
    def on_fescape(flag, exp)
      [:fescape, flag, compile(exp)]
    end
  end
  ::Temple::Filter.include FescapeDispathcer

  # Unlike Haml::Escapable, this escapes value even if it's html_safe.
  class ForceEscapable < Escapable
    def initialize(opts = {})
      super
      @escape_code = options[:escape_code] || "::Haml::Util.escape_html((%s))"
      @escaper = eval("proc {|v| #{@escape_code % 'v'} }")
    end

    alias_method :on_fescape, :on_escape

    # ForceEscapable doesn't touch :escape expression.
    # This method is not used if it's inserted after Haml::Escapable.
    def on_escape(flag, exp)
      [:escape, flag, compile(exp)]
    end
  end
end

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
haml-6.0.12-java lib/haml/force_escapable.rb
haml-6.0.12 lib/haml/force_escapable.rb
haml-6.0.11-java lib/haml/force_escapable.rb
haml-6.0.11 lib/haml/force_escapable.rb
haml-6.0.10-java lib/haml/force_escapable.rb
haml-6.0.10 lib/haml/force_escapable.rb
haml-6.0.9-java lib/haml/force_escapable.rb
haml-6.0.9 lib/haml/force_escapable.rb
haml-6.0.8-java lib/haml/force_escapable.rb
haml-6.0.8 lib/haml/force_escapable.rb
haml-6.0.7-java lib/haml/force_escapable.rb
haml-6.0.7 lib/haml/force_escapable.rb
haml-6.0.6-java lib/haml/force_escapable.rb
haml-6.0.6 lib/haml/force_escapable.rb
haml-6.0.5-java lib/haml/force_escapable.rb
haml-6.0.5 lib/haml/force_escapable.rb
haml-6.0.4-java lib/haml/force_escapable.rb
haml-6.0.4 lib/haml/force_escapable.rb
haml-6.0.3-java lib/haml/force_escapable.rb
haml-6.0.3 lib/haml/force_escapable.rb