Пример #1
0
 public function content()
 {
     if (!$this->_cached) {
         if (method_exists($this, 'display')) {
             // capture output
             ob_start();
             $this->display($this->_args);
             $buffer = ob_get_clean();
             // if no content is produced but there was direct ouput we set
             // that output as content
             if (!$this->_content && $buffer) {
                 $this->set($buffer);
             }
         }
     }
     return parent::content();
 }
Пример #2
0
 /**
  * Create a partial object with an optional default content
  * Can be usefull to use straight from the template file
  * @param string $name
  * @param string $default
  * @return Partial
  */
 public function partial($name, $default = FALSE)
 {
     if ($this->exists($name)) {
         $partial = $this->_partials[$name];
     } else {
         // create new partial
         $partial = new Partial($name);
         if ($this->_cache_ttl) {
             $partial->cache($this->_cache_ttl);
         }
         // detect local triggers
         if (method_exists($this, 'trigger_' . $name)) {
             $partial->bind($this, 'trigger_' . $name);
         }
         $this->_partials[$name] = $partial;
     }
     if (!$partial->content() && $default) {
         $partial->set($default);
     }
     return $partial;
 }