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 415 415: def builder(template=nil, options={}, locals={}, &block) 416: render_xml(:builder, template, options, locals, &block) 417: end
# File lib/sinatra/base.rb, line 443 443: def coffee(template, options={}, locals={}) 444: options.merge! :layout => false, :default_content_type => :js 445: render :coffee, template, options, locals 446: end
# File lib/sinatra/base.rb, line 388 388: def erb(template, options={}, locals={}) 389: render :erb, template, options, locals 390: end
# File lib/sinatra/base.rb, line 392 392: def erubis(template, options={}, locals={}) 393: render :erubis, template, options, locals 394: end
# File lib/sinatra/base.rb, line 396 396: def haml(template, options={}, locals={}) 397: render :haml, template, options, locals 398: end
# File lib/sinatra/base.rb, line 410 410: def less(template, options={}, locals={}) 411: options.merge! :layout => false, :default_content_type => :css 412: render :less, template, options, locals 413: end
# File lib/sinatra/base.rb, line 419 419: def liquid(template, options={}, locals={}) 420: render :liquid, template, options, locals 421: end
# File lib/sinatra/base.rb, line 439 439: def markaby(template, options={}, locals={}) 440: render :mab, template, options, locals 441: end
# File lib/sinatra/base.rb, line 423 423: def markdown(template, options={}, locals={}) 424: render :markdown, template, options, locals 425: end
# File lib/sinatra/base.rb, line 448 448: def nokogiri(template=nil, options={}, locals={}, &block) 449: options[:layout] = false if Tilt::VERSION <= "1.1" 450: render_xml(:nokogiri, template, options, locals, &block) 451: end
# File lib/sinatra/base.rb, line 435 435: def radius(template, options={}, locals={}) 436: render :radius, template, options, locals 437: end
# File lib/sinatra/base.rb, line 431 431: def rdoc(template, options={}, locals={}) 432: render :rdoc, template, options, locals 433: end
# File lib/sinatra/base.rb, line 400 400: def sass(template, options={}, locals={}) 401: options.merge! :layout => false, :default_content_type => :css 402: render :sass, template, options, locals 403: end
# File lib/sinatra/base.rb, line 405 405: def scss(template, options={}, locals={}) 406: options.merge! :layout => false, :default_content_type => :css 407: render :scss, template, options, locals 408: end