##Notes
Type | Sinatra | Rails | Notes |
---|---|---|---|
Partials | <%= erb :_menu %> |
<%= render "menu" %> |
the underscore is implied, such that this will render the file named _menu.html.erb |
Partial from another directory | <%= erb :_menu %> |
<%= render "shared/menu" %> |
--- |
Partial layouts | --- | <%= render :partial => "link_area", :layout => "graybar" %> |
Note that explicitly specifying :partial is required when passing additional options such as :layout. Layouts also follow the leading underscore convention, e.g., _graybar.html.erb |
Pass local variables via partials, part 1 | --- | <%= render :partial => "form", :locals => { :zone => @zone } %> |
|
Pass local variables via partials, part 2 | --- | <%= render :partial => "customer", :object => @new_customer %> |
Every partial has a local variable with the same name as the partial (minus the underscore). You can pass an object in to this local variable via the :object option. |
Shorthand | --- | `<%= render @customer %> |