Sha256: f53dc07eac533f89a1eeef62a39da5f3cc119e4daf70ce91fcda6722b7b24552
Contents?: true
Size: 665 Bytes
Versions: 1
Compression:
Stored size: 665 Bytes
Contents
require 'sinatra/base' module Sinatra module DefaultTemplates module Helpers 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 end def self.registered(app) app.helpers DefaultTemplates::Helpers; app.not_found do render_template_if_exists! end end end register Sinatra::DefaultTemplates end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
sinatra-default-templates-1.0.0 | lib/sinatra/default_templates.rb |