本文整理匯總了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;
}