/**
  * Compile template source and run optional post filter
  *
  * @param \Smarty_Internal_Template             $template
  * @param null|bool                             $nocache flag if template must be compiled in nocache mode
  * @param \Smarty_Internal_TemplateCompilerBase $parent_compiler
  *
  * @return string
  * @throws \Exception
  */
 public function compileTemplateSource(Smarty_Internal_Template $template, $nocache = null, Smarty_Internal_TemplateCompilerBase $parent_compiler = null)
 {
     try {
         // save template object in compiler class
         $this->template = $template;
         if (property_exists($this->template->smarty, 'plugin_search_order')) {
             $this->plugin_search_order = $this->template->smarty->plugin_search_order;
         }
         if ($this->smarty->debugging) {
             $this->smarty->_debug->start_compile($this->template);
         }
         if (isset($this->template->smarty->security_policy)) {
             $this->php_handling = $this->template->smarty->security_policy->php_handling;
         } else {
             $this->php_handling = $this->template->smarty->php_handling;
         }
         $this->parent_compiler = $parent_compiler ? $parent_compiler : $this;
         $nocache = isset($nocache) ? $nocache : false;
         if (empty($template->compiled->nocache_hash)) {
             $template->compiled->nocache_hash = $this->nocache_hash;
         } else {
             $this->nocache_hash = $template->compiled->nocache_hash;
         }
         // flag for nocache sections
         $this->nocache = $nocache;
         $this->tag_nocache = false;
         // reset has nocache code flag
         $this->template->compiled->has_nocache_code = false;
         $this->has_variable_string = false;
         $this->prefix_code = array();
         // add file dependency
         $this->parent_compiler->template->compiled->file_dependency[$this->template->source->uid] = array($this->template->source->filepath, $this->template->source->getTimeStamp(), $this->template->source->type);
         $this->smarty->_current_file = $this->template->source->filepath;
         // get template source
         if (!empty($this->template->source->components)) {
             // we have array of inheritance templates by extends: resource
             // generate corresponding source code sequence
             $_content = Smarty_Internal_Compile_Extends::extendsSourceArrayCode($this->template->source->components);
         } else {
             // get template source
             $_content = $this->template->source->getContent();
         }
         $_compiled_code = $this->postFilter($this->doCompile($this->preFilter($_content), true));
     } catch (Exception $e) {
         if ($this->smarty->debugging) {
             $this->smarty->_debug->end_compile($this->template);
         }
         $this->_tag_stack = array();
         self::$_tag_objects = array();
         // free memory
         $this->parent_compiler = null;
         $this->template = null;
         $this->parser = null;
         throw $e;
     }
     if ($this->smarty->debugging) {
         $this->smarty->_debug->end_compile($this->template);
     }
     $this->parent_compiler = null;
     $this->parser = null;
     return $_compiled_code;
 }
function smarty_compiler_layout($params, Smarty $smarty)
{
    $template_object_key = array_shift(array_keys($smarty->template_objects));
    $extends = new Smarty_Internal_Compile_Extends();
    return $extends->compile($params);
}