Module: Sinatra::Templates
- Included in:
- Base
- Defined in:
- lib/sinatra/base.rb
Overview
Template rendering methods. Each method takes a the name of a template to render as a Symbol and returns a String with the rendered output.
Instance Method Summary collapse
- #builder(template = nil, options = {}, &block) ⇒ Object
- #erb(template, options = {}) ⇒ Object
- #haml(template, options = {}) ⇒ Object
- #sass(template, options = {}, &block) ⇒ Object
Instance Method Details
#builder(template = nil, options = {}, &block) ⇒ Object
231 232 233 234 235 236 |
# File 'lib/sinatra/base.rb', line 231 def builder(template=nil, ={}, &block) require 'builder' unless defined? ::Builder , template = template, nil if template.is_a?(Hash) template = lambda { block } if template.nil? render :builder, template, end |
#erb(template, options = {}) ⇒ Object
214 215 216 217 |
# File 'lib/sinatra/base.rb', line 214 def erb(template, ={}) require 'erb' unless defined? ::ERB render :erb, template, end |
#haml(template, options = {}) ⇒ Object
219 220 221 222 223 |
# File 'lib/sinatra/base.rb', line 219 def haml(template, ={}) require 'haml' unless defined? ::Haml [:options] ||= self.class.haml if self.class.respond_to? :haml render :haml, template, end |
#sass(template, options = {}, &block) ⇒ Object
225 226 227 228 229 |
# File 'lib/sinatra/base.rb', line 225 def sass(template, ={}, &block) require 'sass' unless defined? ::Sass [:layout] = false render :sass, template, end |