本文整理匯總了PHP中h2o::parseString方法的典型用法代碼示例。如果您正苦於以下問題:PHP h2o::parseString方法的具體用法?PHP h2o::parseString怎麽用?PHP h2o::parseString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類h2o
的用法示例。
在下文中一共展示了h2o::parseString方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: should_apply_filter_if_available
function should_apply_filter_if_available()
{
$name = 'taylor luk';
$result = h2o::parseString('{{ name|capitalize }}')->render(compact('name'));
expects($result)->should_be('Taylor Luk');
}
示例2: __construct
function __construct($argstring, $parser, $position = 0)
{
if (!preg_match($this->syntax, $argstring, $matches)) {
throw new TemplateSyntaxError();
}
$matches_count = count($matches);
if ($matches_count > 2) {
// "with" statement supplied.
$with_vars = explode(' ', $matches[3]);
foreach ($with_vars as $var_str) {
$eq_pos = strpos($var_str, '=');
$this->_additional_context[substr($var_str, 0, $eq_pos)] = substr($var_str, $eq_pos + 1);
}
}
$this->filename = stripcslashes($matches[1]);
$this->fname_tpl = h2o::parseString($this->filename, $parser->options);
if ($this->fname_tpl->render() != $this->filename) {
$this->dynamic = True;
$this->loader = $parser->runtime;
} else {
$this->dynamic = False;
$this->nodelist = $parser->runtime->loadSubTemplate($this->filename, $parser->options);
$parser->storage['templates'] = array_merge($this->nodelist->parser->storage['templates'], $parser->storage['templates']);
$parser->storage['templates'][] = $this->filename;
}
}