Method: ActionView::Template::Handlers#register_template_handler

Defined in:
actionview/lib/action_view/template/handlers.rb

#register_template_handler(*extensions, handler) ⇒ Object

Register an object that knows how to handle template files with the given extensions. This can be used to implement new template types. The handler must respond to :call, which will be passed the template and should return the rendered template as a String.

Raises:

  • (ArgumentError)


31
32
33
34
35
36
37
# File 'actionview/lib/action_view/template/handlers.rb', line 31

def register_template_handler(*extensions, handler)
  raise(ArgumentError, "Extension is required") if extensions.empty?
  extensions.each do |extension|
    @@template_handlers[extension.to_sym] = handler
  end
  @@template_extensions = nil
end