예제 #1
0
 public function render()
 {
     if (!empty($this->_items)) {
         if ($this->_num_rows > 2) {
             $col_xs = @round(12 / ($this->_num_per_rows - 2));
             $col_sm = @round(12 / ($this->_num_per_rows - 1));
         }
         $col_md = round(12 / $this->_num_per_rows);
         $col_lg = round(12 / $this->_num_per_rows);
         $container = new Tag('div', ['class' => 'row']);
         foreach ($this->_items as $key => $item) {
             $column = new Tag('div', $item, ['class' => 'grid-item']);
             if (isset($col_xs)) {
                 $column->add_class('col-xs-' . $col_xs);
             }
             if (isset($col_sm)) {
                 $column->add_class('col-sm-' . $col_sm);
             }
             $column->add_class('col-md-' . $col_md);
             $column->add_class('col-lg-' . $col_lg);
             $this->_items[$key] = $column;
         }
         $container->set_content(implode(PHP_EOL, $this->_items));
         return (new Tag($this->_tag, $container, $this->_attributes))->render();
     }
     return '';
 }