Module: EZML::Filters

Extended by:
Filters
Included in:
Filters
Defined in:
lib/ezml/filters.rb

Defined Under Namespace

Modules: Base, Cdata, Coffee, Css, Erb, Escaped, Javascript, Less, Markdown, Plain, PrecompiledTiltFilter, Preserve, Ruby, Sass, Scss, TiltFilter

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#definedObject (readonly)

Returns the value of attribute defined.



8
9
10
# File 'lib/ezml/filters.rb', line 8

def defined
  @defined
end

Instance Method Details

#register_tilt_filter(name, options = {}) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/ezml/filters.rb', line 11

def register_tilt_filter(name, options = {})
  if constants.map(&:to_s).include?(name.to_s)
    raise "#{name} filter already defined"
  end

  filter = const_set(name, Module.new)
  filter.extend const_get(options[:extend] || "Plain")
  filter.extend TiltFilter
  filter.extend PrecompiledTiltFilter if options.has_key? :precompiled

  if options.has_key? :template_class
    filter.template_class = options[:template_class]
  else
    filter.tilt_extension = options.fetch(:extension) { name.downcase }
  end

  # All ":coffeescript" as alias for ":coffee", etc.
  if options.has_key?(:alias)
    [options[:alias]].flatten.each {|x| Filters.defined[x.to_s] = filter}
  end
  filter
end

#remove_filter(name) ⇒ Object



34
35
36
37
38
39
# File 'lib/ezml/filters.rb', line 34

def remove_filter(name)
  defined.delete name.to_s.downcase
  if constants.map(&:to_s).include?(name.to_s)
    remove_const name.to_sym
  end
end