Class Misago\ActionView\Base

Renders templates.

See Misago\ActionController\Base::render() for actual help, since you shall not need to use this object directly, except for a few methods, like yield or rendering partials.



Public instance attributes

Protected instance attributes


Public instance methods



Renders a template (view, layout or partial).

Generic option(s):

  • format - which format to use? defaults to html

Render a view:

render(array('action' => 'index')); 

This will render the view index.html.tpl.

Render a partial:

render(array('partial' => 'form'));
render(array('partial' => 'form', 'locals' => array('f' => $f))); 

This will render the partial _form.html.tpl.

Render a collection of partials:

render(array('partial' => 'product', 'collection' => $products)); 

The collection must be an array or an iterable object. This will create the following local vars: $product and $product_counter.

Rendering shared partials

You may share partials between controllers.

render(array('partial' => 'posts/post'));
render(array('partial' => 'posts/post', 'collection' => $posts)); 

This will render the partial posts/_post.html.tpl, regardless of which controller this is being called from.

template_exists($template, $format=null)

Returns true if a given template exists.

yield($name, $content=null)

Passes data from a template to another. For instance from view to layout, partial to view, etc.