Propel API
Class

PropelTemplate

class PropelTemplate

Simple templating system to ease behavior writing

Methods

setTemplate(string $template)

Set a string as a template.

setTemplateFile(string $filePath)

Set a file as a template.

string render(array $vars = array())

Render the template using the variable provided as arguments.

Details

at line 32
public setTemplate(string $template)

Set a string as a template.

The string doesn't need closing php tags.

<code>
$template->setTemplate('This is <?php echo $name ?>');
</code>

Parameters

string $template the template string

at line 46
public setTemplateFile(string $filePath)

Set a file as a template.

The file can be any regular PHP file.

<code>
$template->setTemplateFile(dirname(__FILE__) . '/template/foo.php');
</code>

Parameters

string $filePath The (absolute or relative to the include path) file path

at line 68
public string render(array $vars = array())

Render the template using the variable provided as arguments.

<code>
$template = new PropelTemplate();
$template->setTemplate('This is <?php echo $name ?>');
echo $template->render(array('name' => 'Mike'));
// This is Mike
</code>

Parameters

array $vars An associative array of argumens to be rendered

Return Value

string The rendered template

Exceptions

InvalidArgumentException
Exception