Sha256: 11372092b708db0a983bd24ab4ac9569c464ad538a89c8413b3b2ecb527f6a94
Contents?: true
Size: 1.21 KB
Versions: 19
Compression:
Stored size: 1.21 KB
Contents
require 'sinatra/base' require 'sinatra_more' require 'haml' class RenderUser attr_accessor :name def initialize(name); @name = name; end end class RenderDemo < Sinatra::Base register SinatraMore::RenderPlugin configure do set :root, File.dirname(__FILE__) end # haml_template get '/render_haml' do @template = 'haml' haml_template 'haml/test' end # erb_template get '/render_erb' do @template = 'erb' erb_template 'erb/test' end # render_template with explicit engine get '/render_template/:engine' do @template = params[:engine] render_template "template/#{@template}_template", :template_engine => @template end # render_template without explicit engine get '/render_template' do render_template "template/some_template" end # partial with object get '/partial/object' do partial 'template/user', :object => RenderUser.new('John') end # partial with collection get '/partial/collection' do partial 'template/user', :collection => [RenderUser.new('John'), RenderUser.new('Billy')] end # partial with locals get '/partial/locals' do partial 'template/user', :locals => { :user => RenderUser.new('John') } end end
Version data entries
19 entries across 19 versions & 1 rubygems