當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Smarty_Internal_Template::loadCompiler方法代碼示例

本文整理匯總了PHP中Smarty_Internal_Template::loadCompiler方法的典型用法代碼示例。如果您正苦於以下問題:PHP Smarty_Internal_Template::loadCompiler方法的具體用法?PHP Smarty_Internal_Template::loadCompiler怎麽用?PHP Smarty_Internal_Template::loadCompiler使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Smarty_Internal_Template的用法示例。


在下文中一共展示了Smarty_Internal_Template::loadCompiler方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: process

 /**
  * compile template from source
  *
  * @param Smarty_Internal_Template $_smarty_tpl do not change variable name, is used by compiled template
  *
  * @throws Exception
  */
 public function process(Smarty_Internal_Template $_smarty_tpl)
 {
     $compiled =& $_smarty_tpl->compiled;
     $compiled->file_dependency = array();
     $compiled->includes = array();
     $compiled->nocache_hash = null;
     $compiled->unifunc = null;
     $level = ob_get_level();
     ob_start();
     $_smarty_tpl->loadCompiler();
     // call compiler
     try {
         eval("?>" . $_smarty_tpl->compiler->compileTemplate($_smarty_tpl));
     } catch (Exception $e) {
         unset($_smarty_tpl->compiler);
         while (ob_get_level() > $level) {
             ob_end_clean();
         }
         throw $e;
     }
     // release compiler object to free memory
     unset($_smarty_tpl->compiler);
     ob_get_clean();
     $compiled->timestamp = time();
     $compiled->exists = true;
 }
開發者ID:thekabal,項目名稱:tki,代碼行數:33,代碼來源:smarty_resource_recompiled.php

示例2: compileTemplateSource

 /**
  * compile template from source
  *
  * @param Smarty_Internal_Template $_template
  *
  * @return string
  * @throws Exception
  */
 public function compileTemplateSource(Smarty_Internal_Template $_template)
 {
     $this->file_dependency = array();
     $this->includes = array();
     $this->nocache_hash = null;
     $this->unifunc = null;
     // compile locking
     if (!$_template->source->handler->recompiled) {
         if ($saved_timestamp = $this->getTimeStamp()) {
             touch($this->filepath);
         }
     }
     // call compiler
     try {
         $_template->loadCompiler();
         $code = $_template->compiler->compileTemplate($_template);
     } catch (Exception $e) {
         // restore old timestamp in case of error
         if (!$_template->source->handler->recompiled && $saved_timestamp) {
             touch($this->filepath, $saved_timestamp);
         }
         throw $e;
     }
     // compiling succeeded
     if ($_template->compiler->write_compiled_code) {
         // write compiled template
         $this->write($_template, $code);
         $code = '';
     }
     // release compiler object to free memory
     unset($_template->compiler);
     return $code;
 }
開發者ID:vanderlee,項目名稱:smarty,代碼行數:41,代碼來源:smarty_template_compiled.php

示例3: compileInlineTemplate

 /**
  * Compile inline sub template
  *
  * @param \Smarty_Internal_SmartyTemplateCompiler $compiler
  * @param \Smarty_Internal_Template               $tpl
  * @param  string                                 $t_hash
  *
  * @return bool
  */
 public function compileInlineTemplate(Smarty_Internal_SmartyTemplateCompiler $compiler, Smarty_Internal_Template $tpl, $t_hash)
 {
     $uid = $tpl->source->type . $tpl->source->uid;
     if (!$tpl->source->handler->uncompiled && $tpl->source->exists) {
         $compiler->parent_compiler->mergedSubTemplatesData[$uid][$t_hash]['uid'] = $tpl->source->uid;
         if (isset($compiler->template->inheritance)) {
             $tpl->inheritance = clone $compiler->template->inheritance;
         }
         $tpl->compiled = new Smarty_Template_Compiled();
         $tpl->compiled->nocache_hash = $compiler->parent_compiler->template->compiled->nocache_hash;
         $tpl->loadCompiler();
         // save unique function name
         $compiler->parent_compiler->mergedSubTemplatesData[$uid][$t_hash]['func'] = $tpl->compiled->unifunc = 'content_' . str_replace(array('.', ','), '_', uniqid('', true));
         // make sure whole chain gets compiled
         $tpl->mustCompile = true;
         $compiler->parent_compiler->mergedSubTemplatesData[$uid][$t_hash]['nocache_hash'] = $tpl->compiled->nocache_hash;
         if ($compiler->template->source->type == 'file') {
             $sourceInfo = $compiler->template->source->filepath;
         } else {
             $basename = $compiler->template->source->handler->getBasename($compiler->template->source);
             $sourceInfo = $compiler->template->source->type . ':' . ($basename ? $basename : $compiler->template->source->name);
         }
         // get compiled code
         $compiled_code = "<?php\n\n";
         $compiled_code .= "/* Start inline template \"{$sourceInfo}\" =============================*/\n";
         $compiled_code .= "function {$tpl->compiled->unifunc} (\$_smarty_tpl) {\n";
         $compiled_code .= "?>\n" . $tpl->compiler->compileTemplateSource($tpl, null, $compiler->parent_compiler);
         $compiled_code .= "<?php\n";
         $compiled_code .= "}\n?>\n";
         $compiled_code .= $tpl->compiler->postFilter($tpl->compiler->blockOrFunctionCode);
         $compiled_code .= "<?php\n\n";
         $compiled_code .= "/* End inline template \"{$sourceInfo}\" =============================*/\n";
         $compiled_code .= "?>";
         unset($tpl->compiler);
         if ($tpl->compiled->has_nocache_code) {
             // replace nocache_hash
             $compiled_code = str_replace("{$tpl->compiled->nocache_hash}", $compiler->template->compiled->nocache_hash, $compiled_code);
             $compiler->template->compiled->has_nocache_code = true;
         }
         $compiler->parent_compiler->mergedSubTemplatesCode[$tpl->compiled->unifunc] = $compiled_code;
         return true;
     } else {
         return false;
     }
 }
開發者ID:jimjag,項目名稱:smarty,代碼行數:54,代碼來源:smarty_internal_compile_include.php

示例4: compileTemplateSource

 /**
  * compile template from source
  *
  * @param Smarty_Internal_Template $_template
  *
  * @return string
  * @throws Exception
  */
 public function compileTemplateSource(Smarty_Internal_Template $_template)
 {
     // compile locking
     if (!$_template->source->recompiled) {
         if ($saved_timestamp = $_template->compiled->timestamp) {
             touch($_template->compiled->filepath);
         }
     }
     $level = ob_get_level();
     try {
         $_template->loadCompiler();
         $code = $_template->compiler->compileTemplate($_template);
     } catch (Exception $e) {
         $_template->context = null;
         while (ob_get_level() > $level) {
             ob_end_clean();
         }
         // restore old timestamp in case of error
         if (!$_template->source->recompiled && $saved_timestamp) {
             touch($_template->compiled->filepath, $saved_timestamp);
         }
         throw $e;
     }
     // compiling succeeded
     if ($_template->compiler->write_compiled_code) {
         // write compiled template
         $this->write($_template, $code);
         $code = '';
     }
     // release compiler object to free memory
     unset($_template->compiler);
     return $code;
 }
開發者ID:uwetews,項目名稱:smarty-hhvm,代碼行數:41,代碼來源:smarty_template_compiled.php

示例5: compileTemplateSource

 /**
  * compile template from source
  *
  * @param Smarty_Internal_Template $_template
  *
  * @throws Exception
  */
 public function compileTemplateSource(Smarty_Internal_Template $_template)
 {
     $this->file_dependency = array();
     $this->includes = array();
     $this->nocache_hash = null;
     $this->unifunc = null;
     // compile locking
     $saved_timestamp = $_template->source->handler->recompiled ? false : $this->getTimeStamp();
     if ($saved_timestamp) {
         touch($this->filepath);
     }
     // compile locking
     try {
         // call compiler
         $_template->loadCompiler();
         $this->write($_template, $_template->compiler->compileTemplate($_template));
     } catch (Exception $e) {
         // restore old timestamp in case of error
         if ($saved_timestamp) {
             touch($this->filepath, $saved_timestamp);
         }
         unset($_template->compiler);
         throw $e;
     }
     // release compiler object to free memory
     unset($_template->compiler);
 }
開發者ID:jimjag,項目名稱:smarty,代碼行數:34,代碼來源:smarty_template_compiled.php

示例6: compileTemplateSource

 /**
  * compile template from source
  *
  * @param Smarty_Internal_Template $_template
  *
  * @throws Exception
  */
 public function compileTemplateSource(Smarty_Internal_Template $_template)
 {
     $this->file_dependency = array();
     $this->includes = array();
     $this->nocache_hash = null;
     $this->unifunc = null;
     // compile locking
     if ($saved_timestamp = $this->getTimeStamp()) {
         touch($this->filepath);
     }
     // call compiler
     $_template->loadCompiler();
     $this->write($_template, $_template->compiler->compileTemplate($_template));
     // release compiler object to free memory
     unset($_template->compiler);
 }
開發者ID:thekabal,項目名稱:tki,代碼行數:23,代碼來源:smarty_template_compiled.php


注:本文中的Smarty_Internal_Template::loadCompiler方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。