Module: Sinatra::DefaultTemplates::Helpers

Defined in:
lib/sinatra/default_templates.rb

Instance Method Summary collapse

Instance Method Details

#render_template_if_exists!Object



7
8
9
10
11
12
13
14
# File 'lib/sinatra/default_templates.rb', line 7

def render_template_if_exists!
  name = File.basename(request.path)
  Dir["#{options.views}/#{name}.*"].each do |match|
    @_format = File.extname(match).sub(/^./, '')
    @_template = File.basename(match, File.extname(match))
  end
  eval("#{@_format} :#{@_template}") if @_format and @_template
end