Propel 2 API
Class

Propel\Generator\Builder\Util\PropelTemplate

class PropelTemplate

Simple templating system to ease behavior writing

Methods

setTemplate(string $template)

Sets 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 42
public setTemplate(string $template)

Sets 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 56
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 75
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 arguments to be rendered

Return Value

string The rendered template