Tilt

Constants

VERSION

Public Class Methods

[](file) click to toggle source

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
31:   def self.[](file)
32:     if @template_mappings.key?(pattern = file.to_s.downcase)
33:       @template_mappings[pattern]
34:     elsif @template_mappings.key?(pattern = File.basename(pattern))
35:       @template_mappings[pattern]
36:     else
37:       while !pattern.empty?
38:         if @template_mappings.key?(pattern)
39:           return @template_mappings[pattern]
40:         else
41:           pattern = pattern.sub(/^[^.]*\.?/, '')
42:         end
43:       end
44:       nil
45:     end
46:   end
mappings() click to toggle source

Hash of template path pattern => template implementation class mappings.

    # File lib/sinatra/tilt.rb, line 9
 9:   def self.mappings
10:     @template_mappings
11:   end
new(file, line=nil, options={}, &block) click to toggle source

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
21:   def self.new(file, line=nil, options={}, &block)
22:     if template_class = self[file]
23:       template_class.new(file, line, options, &block)
24:     else
25:       fail "No template engine registered for #{File.basename(file)}"
26:     end
27:   end
register(ext, template_class) click to toggle source

Register a template implementation by file extension.

    # File lib/sinatra/tilt.rb, line 14
14:   def self.register(ext, template_class)
15:     ext = ext.to_s.sub(/^\./, '')
16:     mappings[ext.downcase] = template_class
17:   end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.