# Class: Haml::ForceEscape

Inherits:
  Escape
  - Object
  - Temple::Filters::Escapable
  - Escape
  - Haml::ForceEscape
  show all

Defined in:
  lib/haml/force_escape.rb

## Overview

Unlike Haml::Escape, this escapes value even if it’s html_safe.

## Instance Method Summary collapse

- #initialize(opts = {}) ⇒ ForceEscape constructor

  A new instance of ForceEscape.

- #on_escape(flag, exp)

  ForceEscape doesn’t touch :escape expression.

- #on_fescape

## Constructor Details

### #initialize(opts = {}) ⇒ `ForceEscape`

Returns a new instance of ForceEscape.

    15
    16
    17
    18
    19

    # File 'lib/haml/force_escape.rb', line 15

    def initialize(opts = {})
      super
      @escape_code = options[:escape_code] || "::Haml::Util.escape_html((%s))"
      @escaper = eval("proc {|v| #{@escape_code % 'v'} }")
    end

## Instance Method Details

### #on_escape(flag, exp)

ForceEscape doesn’t touch :escape expression. This method is not used if it’s inserted after Haml::Escape.

    25
    26
    27

    # File 'lib/haml/force_escape.rb', line 25

    def on_escape(flag, exp)
      [:escape, flag, compile(exp)]
    end

### #on_fescape

    21

    # File 'lib/haml/force_escape.rb', line 21

    alias_method :on_fescape, :on_escape