Module: Templette::Engineer

Defined in:
lib/templette/engineer.rb

Overview

The engineer is simply in charge of the engines.

Additional templating languages can be supported by adding a class in the Templette::Engines module which implements render(html, the_binding) in the templates/engines/ folder. Name the class the same as the ‘type’ for the template.

Constant Summary collapse

ENGINES_DIR =
File.dirname(__FILE__) + "/engines/"
@@engines =
{}

Class Method Summary collapse

Class Method Details

.determine_type(filename) ⇒ Object



23
24
25
# File 'lib/templette/engineer.rb', line 23

def self.determine_type(filename)
  filename.match(/html\.?(\w+)?/)[1] || Templette::config[:default_engine]
end

.engine_for(type) ⇒ Object

Takes a string type and attempts to load a rendering engine of the same name. If the Engine is found, an instance of the class will be returned. A failure to find a matching engine file will result in a RenderError.



19
20
21
# File 'lib/templette/engineer.rb', line 19

def self.engine_for(type)
  load_engine(type)
end