class Tilt::BaseMapping
Private internal base class for both Mapping and FinalizedMapping, for the shared methods.
def [](file)
-
(template class)
-
def [](file) _, ext = split(file) ext && lookup(ext) end
def new(file, line=nil, options={}, &block)
- See: Tilt::Template.new -
Raises:
-
(RuntimeError)
- if there is no template class registered for the
def 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
def split(file)
def split(file) pattern = file.to_s.downcase full_pattern = pattern.dup until registered?(pattern) return if pattern.empty? pattern = File.basename(pattern) pattern.sub!(/\A[^.]*\.?/, '') end prefix_size = full_pattern.size - pattern.size [full_pattern[0,prefix_size-1], pattern] end
def templates_for(file)
-
(Array)
-
def templates_for(file) templates = [] while true prefix, ext = split(file) break unless ext templates << lookup(ext) file = prefix end templates end