| Module | Sinatra::Templates |
| In: |
lib/sinatra/base.rb
|
Template rendering methods. Each method takes the name of a template to render as a Symbol and returns a String with the rendered output, as well as an optional hash with additional options.
`template` is either the name or path of the template as symbol (Use `:’subdir/myview’` for views in subdirectories), or a string that will be rendered.
Possible options are:
:layout If set to false, no layout is rendered, otherwise
the specified layout is used (Ignored for `sass` and `less`)
:locals A hash with local variables that should be available
in the template
# File lib/sinatra/base.rb, line 324
324: def builder(template=nil, options={}, locals={}, &block)
325: options, template = template, nil if template.is_a?(Hash)
326: template = Proc.new { block } if template.nil?
327: render :builder, template, options, locals
328: end
# File lib/sinatra/base.rb, line 300
300: def erb(template, options={}, locals={})
301: options[:outvar] = '@_out_buf'
302: render :erb, template, options, locals
303: end
# File lib/sinatra/base.rb, line 305
305: def erubis(template, options={}, locals={})
306: options[:outvar] = '@_out_buf'
307: render :erubis, template, options, locals
308: end
# File lib/sinatra/base.rb, line 310
310: def haml(template, options={}, locals={})
311: render :haml, template, options, locals
312: end
# File lib/sinatra/base.rb, line 319
319: def less(template, options={}, locals={})
320: options[:layout] = false
321: render :less, template, options, locals
322: end