/**
  * populate Source Object with meta data from Resource
  *
  * @param Smurty_Template_Source   $source    source object
  * @param Smurty_Internal_Template $_template template object
  *
  * @throws SmurtyException
  */
 public function populate(Smurty_Template_Source $source, Smurty_Internal_Template $_template = null)
 {
     $uid = '';
     $sources = array();
     $components = explode('|', $source->name);
     $exists = true;
     foreach ($components as $component) {
         $s = Smurty_Resource::source(null, $source->smurty, $component);
         if ($s->type == 'php') {
             throw new SmurtyException("Resource type {$s->type} cannot be used with the extends resource type");
         }
         $sources[$s->uid] = $s;
         $uid .= realpath($s->filepath);
         if ($_template && $_template->smurty->compile_check) {
             $exists = $exists && $s->exists;
         }
     }
     $source->components = $sources;
     $source->filepath = $s->filepath;
     $source->uid = sha1($uid);
     if ($_template && $_template->smurty->compile_check) {
         $source->timestamp = $s->timestamp;
         $source->exists = $exists;
     }
     // need the template at getContent()
     $source->template = $_template;
 }
 /**
  * get hiweb_tpl property in template context
  *
  * @param string $property_name property name
  *
  * @throws SmurtyException
  */
 public function __get($property_name)
 {
     switch ($property_name) {
         case 'source':
             if (strlen($this->template_resource) == 0) {
                 throw new SmurtyException('Missing template name');
             }
             $this->source = Smurty_Resource::source($this);
             // cache template object under a unique ID
             // do not cache eval resources
             if ($this->source->type != 'eval') {
                 if ($this->smurty->allow_ambiguous_resources) {
                     $_templateId = $this->source->unique_resource . $this->cache_id . $this->compile_id;
                 } else {
                     $_templateId = $this->smurty->joined_template_dir . '#' . $this->template_resource . $this->cache_id . $this->compile_id;
                 }
                 if (isset($_templateId[150])) {
                     $_templateId = sha1($_templateId);
                 }
                 $this->smurty->template_objects[$_templateId] = $this;
             }
             return $this->source;
         case 'compiled':
             $this->compiled = $this->source->getCompiled($this);
             return $this->compiled;
         case 'cached':
             if (!class_exists('Smurty_Template_Cached')) {
                 include HIWEB_CORE_HTML_ASSETS . 'smurty_cacheresource.php';
             }
             $this->cached = new Smurty_Template_Cached($this);
             return $this->cached;
         case 'compiler':
             $this->smurty->loadPlugin($this->source->compiler_class);
             $this->compiler = new $this->source->compiler_class($this->source->template_lexer_class, $this->source->template_parser_class, $this->smurty);
             return $this->compiler;
             // FIXME: routing of template -> smurty attributes
         // FIXME: routing of template -> smurty attributes
         default:
             if (property_exists($this->smurty, $property_name)) {
                 return $this->smurty->{$property_name};
             }
     }
     throw new SmurtyException("template property '{$property_name}' does not exist.");
 }