Module: EZML::Filters::Base
Class Method Summary collapse
Instance Method Summary collapse
- #compile(compiler, text) ⇒ Object
- #internal_compile(*args) ⇒ Object
- #render(text) ⇒ Object
- #render_with_options(text, options) ⇒ Object
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 [:suppress_eval] text = unescape_interpolation(text, [: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 "find_and_preserve(\#{filter.inspect}.render_with_options(\#{text}, _ezmlout.options))\n".rstrip, :escape_html => false return end rendered = EZML::Helpers::find_and_preserve(filter.(text.to_s, compiler.), compiler.[: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
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 (text, ) render(text) end |