Lookup a template class for the given filename or file extension. Return nil when no implementation is found.
# File lib/sinatra/tilt.rb, line 31 def self.[](file) if @template_mappings.key?(pattern = file.to_s.downcase) @template_mappings[pattern] elsif @template_mappings.key?(pattern = File.basename(pattern)) @template_mappings[pattern] else while !pattern.empty? if @template_mappings.key?(pattern) return @template_mappings[pattern] else pattern = pattern.sub(/^[^.]*\.?/, '') end end nil end end
Hash of template path pattern => template implementation class mappings.
# File lib/sinatra/tilt.rb, line 9 def self.mappings @template_mappings end
Create a new template for the given file using the file’s extension to determine the the template mapping.
# File lib/sinatra/tilt.rb, line 21 def self.new(file, line=nil, options={}, &block) if template_class = self[file] template_class.new(file, line, options, &block) else fail "No template engine registered for #{File.basename(file)}" end end
Generated with the Darkfish Rdoc Generator 2.