module Haml::Filters

def register_tilt_filter(name, options = {})

Other tags:
    Since: - 3.2.0

Options Hash: (**options)
  • :alias (String, Array) -- Any aliases for the filter.
  • :extension (String) -- The extension associated with the
  • :template_class (Class) -- The Tilt template class to use,
  • :precompiled (Boolean) -- Whether the filter should be

Parameters:
  • options (Hash) -- Options for generating the filter module.

Returns:
  • (Module) - The generated filter.
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 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