module EZML::Filters::Base

Public Class Methods

included(base) click to toggle source
# File lib/ezml/filters.rb, line 43
def self.included(base)
  Filters.defined[base.name.split("::").last.downcase] = base
  base.extend(base)
end

Public Instance Methods

compile(compiler, text) click to toggle source
# 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) click to toggle source
# File lib/ezml/filters.rb, line 56
def internal_compile(*args)
  compile(*args)
end
render(text) click to toggle source
# File lib/ezml/filters.rb, line 48
def render(text)
  raise Error.new("#{self.inspect}#render not defined!")
end
render_with_options(text, options) click to toggle source
# File lib/ezml/filters.rb, line 52
def render_with_options(text, options)
  render(text)
end