Module | Merb::RenderMixin |
In: |
lib/merb-core/controller/mixins/render.rb
|
Get the layout that should be used. The content-type will be appended to the layout unless the layout already contains a "." in it.
If no layout was passed in, this method will look for one with the same name as the controller, and finally one in "application.#{content_type}".
layout<~to_s>: | A layout, relative to the layout root. Defaults to nil. |
String: | The method name that corresponds to the found layout. |
TemplateNotFound: | If a layout was specified (either via layout in the class or by passing one in to this method), and not found. No error will be raised if no layout was specified, and the default layouts were not found. |
Iterate over the template roots in reverse order, and return the template and template location of the first match.
context<Object>: | The controller action or template basename. |
content_type<~to_s>: | The content type. Defaults to nil. |
controller<~to_s>: | The name of the controller. Defaults to nil. |
:template<String>: | The location of the template to use. Defaults to whatever matches this context, content_type and controller. |
Array[Symbol, String]: | A pair consisting of the template method and location. |
Called in templates to get at content thrown in another template. The results of rendering a template are automatically thrown into :for_layout, so catch_content or catch_content(:for_layout) can be used inside layouts to get the content rendered by the action template.
obj<Object>: | The key in the thrown_content hash. Defaults to :for_layout. |
all other options options that will be pass to serialization method
like #to_json or #to_xml
The transformed object will not be used in a layout unless a :layout is explicitly passed in the opts.
Render a partial template.
template<~to_s>: | The path to the template, relative to the current controller or the template root. If the template contains a "/", Merb will search for it relative to the template root; otherwise, Merb will search for it relative to the current controller. |
opts<Hash>: | A hash of options (see below) |
:with<Object, Array>: | An object or an array of objects that will be passed into the partial. |
:as<~to_sym>: | The local name of the :with Object inside of the partial. |
:format<Symbol>: | The mime format that you want the partial to be in (:js, :html, etc.) |
others: | A Hash object names and values that will be the local names and values inside the partial. |
partial :foo, :hello => @object
The "_foo" partial will be called, relative to the current controller, with a local variable of hello inside of it, assigned to @object.
Render the specified item, with the specified options.
thing<String, Symbol, nil>: | The thing to render. This will default to the current action |
opts<Hash>: | An options hash (see below) |
:format<Symbol>: | A registered mime-type format |
:template<String>: | The path to the template relative to the template root |
:status<~to_i>: | The status to send to the client. Typically, this would be an integer (200), or a Merb status code (Accepted) |
:layout<~to_s>: | A layout to use instead of the default. This should be relative to the layout root. By default, the layout will be either the controller_name or application. If you want to use an alternative content-type than the one that the base template was rendered as, you will need to do :layout => "foo.#{content_type}" (i.e. "foo.json") |
String: | The rendered template, including layout, if appropriate. |
TemplateNotFound: | There is no template for the specified location. |
If you pass a Hash as the first parameter, it will be moved to opts and "thing" will be the current action
Called in templates to store up content for later use. Takes a string and/or a block. First, the string is evaluated, and then the block is captured using the capture() helper provided by the template languages. The two are concatenated together.
obj<Object>: | The key in the thrown_content hash. |
string<String>: | Textual content. Defaults to nil. |
&block: | A block to be evaluated and concatenated to string. |
ArgumentError: | Neither string nor block given. |
throw_content(:foo, "Foo") catch_content(:foo) #=> "Foo"
Called in templates to test for the existence of previously thrown content.
obj<Object>: | The key in the thrown_content hash. Defaults to :for_layout. |