Represents a PHP Template file

author Jorgen Evens
package WebLab

 Methods

Constructs a new Template

__construct(String $template, String $theme, String $directory) 

Parameters

$template

String

The path to the template, relative to the configured template directory.

$theme

String

The name of the theme to be used. default theme is 'source'

$directory

String

The directory in which to look for the template. Defaults to configuration setting.

Catches all the property calls to return the appropriate variable.

__get(String $name) : Object

Parameters

$name

String

The name of the property (variable) te get.

Returns

ObjectThe value of this property.

Catches all the property calls to set the appropriate variable.

__set(String $name, Object $value) : \WebLab_Template

Parameters

$name

String

The name of the property (variable) being set.

$value

Object

&$value The value to be set.

Returns

\WebLab_TemplateThis template instance.

Returns the value of the function render.

__toString() : String

Returns

StringReturns HTML that has been rendered by the render function. If a Exception occurs the message of this exception will be returned.

Attaches a template as a variable to this template.

attach(\WebLab_Template $template, String $moduleName) : \WebLab_Template
deprecated Use WebLab_Template::set now.

Parameters

$template

\WebLab_Template

Template you would like to attach to this template.

$moduleName

String

Variable name for $template.

Returns

\WebLab_TemplateThis template instance.

Get a template variable.

get(string $variable) : \mixed:

Parameters

$variable

string

Returns

\mixed:

Get the root template for current request.

getRootTemplate() 
Static

Get the entire stack of variables currently attached to this template.

getVars() : Array

Returns

ArrayReturn an array of attached variables. VariableNames as keys.

Renders the template to its compiled HTML form.

render($flush) : mixed

Parameters

$flush

Returns

mixedThe HTML code rendered or true if $show==true

Set a template variable value.

set(string $variable, mixed $value) : \WebLab_Template

Parameters

$variable

string

$value

mixed

Returns

Set the root template for current request.

setRootTemplate(\WebLab_Template $template) 
Static

Parameters

$template

\WebLab_Template

Set the location of the template directory.

setTemplateDir(String $dir) 

This directory contains all of the themes.

Parameters

$dir

String

The directory to look for templates and themes.

Set the theme folder within the template directory.

setTheme(String $dir) : \WebLab_Template

Parameters

$dir

String

Foldername of the theme.

Returns

\WebLab_TemplateThis template instance.

Retrieve cached template

_getCache($path) : string | NULL

Parameters

$path

Returns

stringNULL

Lazy load config.

_getConfig() 
Static

Loads the init component of a template.

_init() 

Injecting headers, scripts or styles should be done here.

Include a component file for current template $component will be attached behind the filename, including a suffix .php

_load(string $component, $extract) 

Parameters

$component

string

$extract

Put cached code

_putCache($path, string $code) 

Parameters

$path

$code

string

Set some default settings for a template.

setBasicVariables() 

 Properties

 

The maximum age in seconds of a cached template.

$max_cache_age : int
 

Contains config for templates.

$_config : \stdClass
 

The directory in which to search for the templates.

$_dir : String
 

$_root : \WebLab_Template
 

Determines if logic should be called.

$_setup : string
 

Contains the path to the template file.

$_template : String
 

The directory of a specific theme. Defaults to 'source'.

$_theme : String
 

All variables assigned to this template.

$_variables : Array