예제 #1
0
 /**
  * Render element to html
  *
  * @return string
  */
 public function toHtml()
 {
     if (!empty($this->template)) {
         return parent::toHtml();
     }
     $this->beforeToHtml();
     $html = '<' . $this->tag . ' ' . $this->renderAttributes();
     if ($this->empty) {
         $html .= ' />';
         return $html;
     } else {
         $html .= '>';
     }
     foreach ($this->content as $content) {
         if ($content instanceof \Magelight\Block) {
             $html .= $content->toHtml();
         } elseif (is_string($content)) {
             $html .= $content;
         }
     }
     $html .= '</' . $this->tag . '>';
     $this->afterToHtml();
     return $html;
 }
예제 #2
0
 /**
  * @return string
  * @throws \Magelight\Exception
  */
 public function toHtml()
 {
     if (!empty($this->template)) {
         return parent::toHtml();
     }
     $this->init();
     $this->beforeToHtml();
     ob_start();
     echo '<!DOCTYPE ' . $this->doctype . '>' . $this->getRootElement()->toHtml();
     $this->afterToHtml();
     $html = ob_get_clean();
     return $html;
 }