File: escape_any.rb

package info (click to toggle)
ruby-haml 6.3.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,004 kB
  • sloc: ruby: 9,908; sh: 23; makefile: 11
file content (21 lines) | stat: -rw-r--r-- 544 bytes parent folder | download | duplicates (2)
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