Documentation

Smarty helper

Table of Contents 

Presentation

This helper is useful for processing Smarty templates within an application, to generate feeds (text, HTML, XML or other) outside the framework's view processing.

It is instantiated via the dependency injection component. Its render() method takes as parameters the path to the Smarty template to be used (absolute path or relative path under the project's templates/ directory), and an associative array containing the variables to be made accessible in the template.

Usage

// template definition
$template = 'path/to/template.tpl';

// template data
$data = [
	'var1' => 'value1',
	'var2' => 'value2',
];

// instanciation through the loader
$html = $this->_loader['\Temma\Utils\Smarty']->render($template, $data);
Previous: Registry helper
Next: Term helper

Table of Contents