File: escape_any.rb

package info (click to toggle)
ruby-haml 7.2.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,996 kB
  • sloc: ruby: 9,939; sh: 23; makefile: 11
file content (21 lines) | stat: -rw-r--r-- 544 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# frozen_string_literal: true
require 'haml/escape'

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

  # Unlike Haml::Escape, this calls to_s when not escaped.
  class EscapeAny < Escape
    alias_method :on_escapeany, :on_escape

    def on_dynamic(value)
      [:dynamic, @escape ? @escape_code % value : "(#{value}).to_s"]
    end
  end
end