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 408 408: def builder(template=nil, options={}, locals={}, &block) 409: render_xml(:builder, template, options, locals, &block) 410: end
# File lib/sinatra/base.rb, line 436 436: def coffee(template, options={}, locals={}) 437: options.merge! :layout => false, :default_content_type => :js 438: render :coffee, template, options, locals 439: end
# File lib/sinatra/base.rb, line 381 381: def erb(template, options={}, locals={}) 382: render :erb, template, options, locals 383: end
# File lib/sinatra/base.rb, line 385 385: def erubis(template, options={}, locals={}) 386: render :erubis, template, options, locals 387: end
# File lib/sinatra/base.rb, line 389 389: def haml(template, options={}, locals={}) 390: render :haml, template, options, locals 391: end
# File lib/sinatra/base.rb, line 403 403: def less(template, options={}, locals={}) 404: options.merge! :layout => false, :default_content_type => :css 405: render :less, template, options, locals 406: end
# File lib/sinatra/base.rb, line 412 412: def liquid(template, options={}, locals={}) 413: render :liquid, template, options, locals 414: end
# File lib/sinatra/base.rb, line 432 432: def markaby(template, options={}, locals={}) 433: render :mab, template, options, locals 434: end
# File lib/sinatra/base.rb, line 416 416: def markdown(template, options={}, locals={}) 417: render :markdown, template, options, locals 418: end
# File lib/sinatra/base.rb, line 441 441: def nokogiri(template=nil, options={}, locals={}, &block) 442: options[:layout] = false if Tilt::VERSION <= "1.1" 443: render_xml(:nokogiri, template, options, locals, &block) 444: end
# File lib/sinatra/base.rb, line 428 428: def radius(template, options={}, locals={}) 429: render :radius, template, options, locals 430: end
# File lib/sinatra/base.rb, line 424 424: def rdoc(template, options={}, locals={}) 425: render :rdoc, template, options, locals 426: end
# File lib/sinatra/base.rb, line 393 393: def sass(template, options={}, locals={}) 394: options.merge! :layout => false, :default_content_type => :css 395: render :sass, template, options, locals 396: end
# File lib/sinatra/base.rb, line 398 398: def scss(template, options={}, locals={}) 399: options.merge! :layout => false, :default_content_type => :css 400: render :scss, template, options, locals 401: end