Module: Flutterby::Filters
- Defined in:
- lib/flutterby/filters.rb
Class Method Summary collapse
Class Method Details
.add(fmts, &blk) ⇒ Object
28 29 30 31 32 |
# File 'lib/flutterby/filters.rb', line 28 def self.add(fmts, &blk) Array(fmts).each do |fmt| define_singleton_method("process_#{fmt}!", &blk) end end |
.apply!(view) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/flutterby/filters.rb', line 11 def self.apply!(view) view._body = view.source.try(:html_safe) # Apply all filters view.node.filters.each do |filter| meth = "process_#{filter}!" if Filters.respond_to?(meth) Filters.send(meth, view) elsif template = tilt(filter, view._body) view._body = template.render(view).html_safe else Flutterby.logger.warn "Unsupported filter '#{filter}' for #{view.node.url}" end end end |
.tilt(format, body, options = {}) ⇒ Object
34 35 36 37 38 39 40 41 42 |
# File 'lib/flutterby/filters.rb', line 34 def self.tilt(format, body, = {}) = { "erb" => { engine_class: Erubis::Auto::EscapedEruby } } = .fetch(format, {}).merge() t = Tilt[format] and t.new() { body } end |