本文整理汇总了PHP中CTemplate::Parse方法的典型用法代码示例。如果您正苦于以下问题:PHP CTemplate::Parse方法的具体用法?PHP CTemplate::Parse怎么用?PHP CTemplate::Parse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CTemplate
的用法示例。
在下文中一共展示了CTemplate::Parse方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Parse
function Parse()
{
$content = $this->_template;
// Mask {{ and }} for later substitution with { and }
$content = str_replace("{{", "_<<<_", $content);
$content = str_replace("}}", "_>>>_", $content);
// Parse includes
$search = "#{INCLUDE}(.*){/INCLUDE}#isU";
preg_match_all($search, $content, $matches, PREG_SET_ORDER);
foreach ($matches as $match) {
$incfile = dirname($this->_tpl_file) . DIRECTORY_SEPARATOR . $match[1];
$t = new CTemplate($incfile);
$t->SetValues($this->_values);
$search = sprintf("#{INCLUDE}%s\\{/INCLUDE}#isU", $match[1]);
$replace = str_replace("\$", "\\\$", $t->Parse());
$content = preg_replace($search, $replace, $content);
}
// Replace single fields
foreach ($this->_values as $token => $value) {
$content = str_replace('{' . $token . '}', $value, $content);
}
// Replace template blocks
foreach ($this->_blockdata as $token => $value) {
$content = str_replace('{BLOCK_' . $token . '}', $value, $content);
}
// Parse PHP
if ($this->_parse_php) {
$content = $this->_parsePHP($content);
}
// Strip empty template placeholders
if (!$this->_debug) {
$content = preg_replace("/{.*}/U", "", $content);
}
// Now convert the {{ and }} replacements back to { and }
$content = str_replace("_<<<_", "{", $content);
$content = str_replace("_>>>_", "}", $content);
// Return content
$this->_content = $content;
return $this->_content;
}