Class: Flue::FilterRegister

Inherits:
Object
  • Object
show all
Defined in:
lib/flue/filter_register.rb

Constant Summary collapse

@@filters =
{}

Class Method Summary collapse

Class Method Details

.filtersObject



5
6
7
# File 'lib/flue/filter_register.rb', line 5

def self.filters
  @@filters
end

.register(ext, filter) ⇒ Object



9
10
11
# File 'lib/flue/filter_register.rb', line 9

def self.register(ext, filter)
  filters[ext.to_s] = filter
end

.run(exts, content, options = {}) ⇒ Object



13
14
15
16
17
18
# File 'lib/flue/filter_register.rb', line 13

def self.run(exts, content, options={})
  f = exts.pop
  return content unless f
  result = run_ext(f, content, options)
  run(exts,result, options)
end

.run_ext(ext, content, options) ⇒ Object



20
21
22
23
24
25
26
# File 'lib/flue/filter_register.rb', line 20

def self.run_ext(ext,content, options)
  if filters[ext]
    filters[ext].new.call(content, options)
  else
    content
  end
end