The base View class.

package Owl
author Dave Widmer

 Methods

Creates a new View instance, if the rendering engine isn't set, it will default to the Mustache engine.

__construct() 

Magic "set" method

__set(string $name, mixed $value) 

Parameters

$name

string

The propery name

$value

mixed

The value to set

Renders the view to html.

__toString() : string

Returns

string

Runs when the view is added to a layout. This will let you assign variables into the layout.

addedToLayout(Layout $layout) 

Parameters

$layout

\Owl\Layout

The layout that this view was added to

The template rendering engine.

getEngine() : \Owl\Engine

Returns

\Owl\EngineThe template rendering engine.

Gets the name of the template file (relative to the template path)

getFile() : string

Returns

string

Gets the finder.

getFinder() : \Owl\Finder

Returns

The partials for this view.

getPartials() : array

Returns

array

Loads a template

load(string $file) : string

Parameters

$file

string

The path of the template file (relative to the $templates_directory)

Returns

stringThe full template

Renders the view into html. All passed in partials should be the full template.

render(array $partials) : string

Parameters

$partials

array

An associative array of $name => $template

Returns

stringThe rendered HTML

Sets parameters in a batch way.

set(mixed $name, mixed $value) : \Owl\View

Parameters

$name

mixed

The property name OR an array of params

$value

mixed

The value of the property if not an array

Returns

\Owl\View$this

Sets the template rendering engine. The engine is static across all View classes so you will only need to set it once.

setEngine(Engine $engine) 

Parameters

$engine

\Owl\Engine

The rendering engine

Set the file finder.

setFinder(Finder $finder) 

Parameters

$finder

\Owl\Finder

The file finder class

 Properties

 

A list of partials in $name => template

$partials : array

 

The rendering engine used to compile the views.

$engine : \Owl\Engine

 

The class used to find template files

$finder : \Owl\Finder