Opciones pasadas a los Métodos de los Templates

Options passed to the render method override options set via set.

Available Options:

  1. locals

    List of locals passed to the document. Handy with partials. Example:

    erb "<%= foo %>", :locals => {:foo => "bar"}
    
  2. default_encoding

    String encoding to use if uncertain. Defaults to

    settings.default_encoding.
    

  3. views

    Views folder to load templates from. Defaults to settings.views.

  4. layout

    Whether to use a layout (true or false), if it's a Symbol, specifies what template to use. Example:

    erb :index, :layout => !request.xhr?
    

  5. content_type

    Content-Type the template produces, default depends on template language.

  6. scope

    Scope to render template under.

    Defaults to the application instance.

    If you change this, instance variables and helper methods will not be available.

  7. layout_engine

    Template engine to use for rendering the layout.

    Useful for languages that do not support layouts otherwise.

    Defaults to the engine used for the template. Example:

    set :rdoc, :layout_engine => :erb
    

  8. layout_options

    Special options only used for rendering the layout. Example:

    set :rdoc, :layout_options => { :views => 'views/layouts' }
    

  9. Templates are assumed to be located directly under the ./views directory.

    To use a different views directory:

    set :views, settings.root + '/templates'
    

  10. One important thing to remember is that you always have to reference templates with symbols, even if they’re in a subdirectory (in this case, use: :'subdir/template' or 'subdir/template'.to_sym).

    You must use a symbol because otherwise rendering methods will render any strings passed to them directly.

Casiano Rodriguez León 2015-01-07