lithium\template\Helper::_render()
Render a string template after applying context filters
Use examples in the Html::link() method:
return $this->_render(__METHOD__, 'link', compact('title', 'url', 'options'), $scope);
Parameters
-
string
$methodname of method that is calling the render (for context filters)
-
string
$stringtemplate key (in Helper::_strings) to render
-
array
$paramsassociated array of template inserts {:key} will be replaced by value
-
array
$optionsAvailable options:
'handlers'array: Before inserting$paramsinside the string template,$this->_context's handlers are applied to each value of$paramsaccording to the key (e.g$params['url'], which is processed by the'url'handler via$this->_context->applyHandler()). The'handlers'option allow to set custom mapping beetween$params's key and$this->_context's handlers. e.g. the following handler:'handlers' => array('url' => 'path')will make$params['url']to be processed by the'path'handler instead of the'url'one.
Returns
stringRendered HTML
Source
protected function _render($method, $string, $params, array $options = array()) {
$strings = $this->_strings;
if (isset($params['options']['scope'])) {
$options['scope'] = $params['options']['scope'];
unset($params['options']['scope']);
}
if ($this->_context) {
foreach ($params as $key => $value) {
$handler = isset($options['handlers'][$key]) ? $options['handlers'][$key] : $key;
$params[$key] = $this->_context->applyHandler(
$this, $method, $handler, $value, $options
);
}
$strings = $this->_context->strings();
}
return String::insert(isset($strings[$string]) ? $strings[$string] : $string, $params);
}