Module: EZML::Filters::Base

Included in:
Cdata, Css, Escaped, Javascript, Plain, Preserve, Ruby
Defined in:
lib/ezml/filters.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



43
44
45
46
# File 'lib/ezml/filters.rb', line 43

def self.included(base)
  Filters.defined[base.name.split("::").last.downcase] = base
  base.extend(base)
end

Instance Method Details

#compile(compiler, text) ⇒ Object



60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/ezml/filters.rb', line 60

def compile(compiler, text)
  filter = self
  compiler.instance_eval do
    if contains_interpolation?(text)
      return if options[:suppress_eval]

      text = unescape_interpolation(text, options[:escape_html]).gsub(/(\\+)n/) do |s|
        escapes = $1.size
        next s if escapes % 2 == 0
        "#{'\\' * (escapes - 1)}\n"
      end
      text = %[\n#{text.sub(/\n"\Z/, "\\n\"")}]
      push_script <<RUBY.rstrip, :escape_html => false
find_and_preserve(#{filter.inspect}.render_with_options(#{text}, _ezmlout.options))
RUBY
      return
    end

    rendered = EZML::Helpers::find_and_preserve(filter.render_with_options(text.to_s, compiler.options), compiler.options[:preserve])
    push_text("#{rendered.rstrip}\n")
  end
end

#internal_compile(*args) ⇒ Object



56
57
58
# File 'lib/ezml/filters.rb', line 56

def internal_compile(*args)
  compile(*args)
end

#render(text) ⇒ Object

Raises:



48
49
50
# File 'lib/ezml/filters.rb', line 48

def render(text)
  raise Error.new("#{self.inspect}#render not defined!")
end

#render_with_options(text, options) ⇒ Object



52
53
54
# File 'lib/ezml/filters.rb', line 52

def render_with_options(text, options)
  render(text)
end