render a table block
195389
protected function renderTable($block)
	{
		$content = "";
		$first = true;
		foreach($block['rows'] as $row) {
            if ($first) {
                if ($row['header']) {
                    $content .= "<thead>\n";
                } else {
                    $content .= "<tbody>\n";
                }
            }
            $content .= "<tr>\n";
            foreach ($row['cells'] as $cell) {
                $tag = $cell['tag'];
                $cellText = $this->renderAbsy($cell['text']);
                if (empty($cellText)) {
                    $cellText = '&nbsp;';
                }
                $content .= "<$tag>$cellText</$tag>\n";
            }
            $content .= "</tr>\n";
            if ($first) {
                if ($row['header']) {
                    $content .= "</thead>\n<tbody>\n";
                }
                $first = false;
            }
		}
		return "<table>\n$content</tbody>\n</table>\n";
	}
1136273
public function render()
    {
        if ($this->config[ 'ordering' ]) {
            $this->attributes->addAttributeClass('table-ordering');
        }

        // Render header
        $tr = $this->header->createRow();

        foreach ($this->columns as $key => $column) {

            $th = $tr->createColumn('th');

            $column[ 'attr' ][ 'data-column' ] = $key;

            foreach ($column[ 'attr' ] as $name => $value) {
                if ( ! empty($value)) {
                    $th->attributes->addAttribute($name, $value);
                }
            }

            if ($column[ 'sorting' ] === true) {
                $icon = new Ui\Contents\Icon('fa fa-sort');
                $icon->attributes->addAttributeClass(['text-muted', 'float-right', 'mt-1']);

                $th->attributes->addAttributeClass('col-sortable');
                $th->attributes->addAttribute('data-toggle', 'sort');
                $th->childNodes->push($icon);
            }

            if ($column[ 'show' ] === false) {
                $th->attributes->addAttributeClass('hidden');
            }

            $th->textContent->push(language()->getLine($column[ 'label' ]));
        }

        // Render tbody
        if ($this->rows->count() > 0) {
            $totalEntries = $this->rows->count();
            $totalRows = $this->rows->countAll();
            $currentPage = input()->get('page') ? input()->get('page') : 1;
            $startNumber = $currentPage == 1 ? 1 : $currentPage * $this->config[ 'entries' ][ 'minimum' ];
            $totalPages = round($totalRows / $this->config[ 'entries' ][ 'minimum' ]);
            $totalPages = $totalPages == 0 && $totalRows > 0 ? 1 : $totalPages;

            $i = $startNumber;
            foreach ($this->rows as $row) {
                $row->numbering = $i;
                $tr = $this->body->createRow();
                $tr->attributes->addAttribute('data-id', $row->id);

                foreach ($this->columns as $key => $column) {

                    $column[ 'key' ] = $key;
                    $td = $tr->createColumn();

                    $column[ 'attr' ][ 'data-column' ] = $key;

                    foreach ($column[ 'attr' ] as $name => $value) {
                        if ( ! empty($value)) {
                            $td->attributes->addAttribute($name, $value);
                        }
                    }

                    if ($column[ 'show' ] === false) {
                        $td->attributes->addAttributeClass('hidden');
                    }

                    $td->attributes->addAttributeClass('col-body-' . $key);

                    $this->renderBodyColumn($td, $column, $row);
                }

                $i++;
            }
        } else {
            $totalEntries = 0;
            $totalRows = 0;
            $currentPage = 1;
            $startNumber = 0;
            $totalPages = 0;
        }

        $showEntries = input()->get('entries') ? input()->get('entries') : $this->config[ 'entries' ][ 'minimum' ];

        // Build table card
        $card = new Ui\Components\Card();
        $card->attributes->addAttribute('data-role', 'table-crud');
        $card->attributes->addAttributeClass('card-table');

        // Build table header tools
        $tools = new Element('div', 'cardHeaderTools');
        $tools->attributes->addAttributeClass(['card-tools', 'float-left']);

        $buttons = new Ui\Components\Buttons\Group();
        foreach ($this->tools as $key => $tool) {
            if ($tool[ 'show' ] === false) {
                continue;
            }

            if ($tool[ 'label' ] === true) {
                $button = $buttons->createButton(language()->getLine('TABLE_BUTTON_' . strtoupper($key)));
                if ( ! empty($tool[ 'icon' ])) {
                    $button->setIcon($tool[ 'icon' ]);
                }
            } else {
                $button = $buttons->createButton(new Ui\Contents\Icon($tool[ 'icon' ]));
                $button->attributes->addAttribute('data-toggle', 'tooltip');
                $button->attributes->addAttribute('title',
                    language()->getLine('TABLE_BUTTON_' . strtoupper($key)));
            }

            if ( ! empty($tool[ 'href' ])) {
                $tool[ 'data-url' ] = $tool[ 'href' ];
            }

            if (isset($tool[ 'attr' ])) {
                foreach ($tool[ 'attr' ] as $name => $value) {
                    $button->attributes->addAttribute($name, $value);
                }
            }

            $button->setContextualClass($tool[ 'contextual' ]);
            $button->smallSize();
            $button->attributes->addAttribute('data-action', $key);
        }

        $tools->childNodes->push($buttons);

        $card->header->childNodes->push($tools);

        // Build table header options
        $options = new Element('div', 'cardHeaderOptions');
        $options->attributes->addAttributeClass(['card-options', 'float-right']);

        $buttons = new Ui\Components\Buttons\Group();
        foreach ($this->options as $key => $option) {
            if ($option[ 'show' ] === false) {
                continue;
            }

            if ($option[ 'label' ] === true) {
                $button = $buttons->createButton(language()->getLine('TABLE_BUTTON_' . strtoupper($key)));
                if ( ! empty($option[ 'icon' ])) {
                    $button->setIcon($option[ 'icon' ]);
                }
            } else {
                $button = $buttons->createButton(new Ui\Contents\Icon($option[ 'icon' ]));
                $button->attributes->addAttribute('data-toggle', 'tooltip');
                $button->attributes->addAttribute('title',
                    language()->getLine('TABLE_BUTTON_' . strtoupper($key)));
            }

            if ( ! empty($option[ 'href' ])) {
                $option[ 'data-url' ] = $option[ 'href' ];
            }

            if (isset($option[ 'attr' ])) {
                foreach ($option[ 'attr' ] as $name => $value) {
                    $button->attributes->addAttribute($name, $value);
                }
            }

            $button->setContextualClass($option[ 'contextual' ]);
            $button->smallSize();
            $button->attributes->addAttribute('data-action', $key);
        }

        $options->childNodes->push($buttons);

        $card->header->childNodes->push($options);

        // Build table body
        $cardBody = $card->createBody();
        $cardBodyRow = $cardBody->createRow();

        $columnSearch = $cardBodyRow->createColumn(['class' => 'col-md-4']);
        $columnShow = $cardBodyRow->createColumn(['class' => 'col-md-8']);

        // Search
        $search = new Ui\Components\Form\Elements\Input([
            'name'        => 'query',
            'data-role'   => 'table-crud-search',
            'placeholder' => language()->getLine('TABLE_LABEL_SEARCH'),
            'value'       => input()->get('query'),
        ]);

        $columnSearch->childNodes->push($search);

        // Show
        $inputGroup = new Ui\Components\Form\Input\Group();

        $addOn = new Ui\Components\Form\Input\Group\AddOn();
        $addOn->textContent->push(language()->getLine('TABLE_LABEL_SHOW'));

        $inputGroup->childNodes->push($addOn);

        $options = [];
        foreach (range((int)$this->config[ 'entries' ][ 'minimum' ], (int)$this->config[ 'entries' ][ 'maximum' ],
            (int)$this->config[ 'entries' ][ 'step' ]) as $entries
        ) {
            $options[ $entries ] = $entries;
        }

        $columnsDropdown = new Ui\Components\Dropdown(language()->getLine('TABLE_LABEL_COLUMNS'));
        $columnsDropdown->attributes->addAttribute('data-role', 'table-crud-columns');

        foreach ($this->columns as $key => $column) {

            if ($column[ 'hiding' ] === false) {
                continue;
            }

            $label = new Ui\Components\Form\Elements\Label();
            $label->attributes->addAttributeClass('form-check-label');
            $label->textContent->push(language()->getLine($column[ 'label' ]));

            $checkbox = new Ui\Components\Form\Elements\Input([
                'type'        => 'checkbox',
                'class'       => 'form-check-input',
                'data-toggle' => 'table-crud-columns',
                'data-column' => $key,
            ]);

            $checkbox->attributes->removeAttributeClass('form-control');

            if ($column[ 'show' ] === true) {
                $checkbox->attributes->addAttribute('checked', 'checked');
            }

            $label->childNodes->push($checkbox);

            $columnsDropdown->menu->createItem($label);
        }

        $inputGroup->childNodes->push($columnsDropdown);

        $select = new Ui\Components\Form\Elements\Select();
        $select->attributes->addAttribute('name', 'entries');
        $select->createOptions($options, $showEntries);
        $inputGroup->childNodes->push($select);

        $addOn = new Ui\Components\Form\Input\Group\AddOn();
        $addOn->textContent->push(language()->getLine('TABLE_LABEL_PAGE', [
            $startNumber,
            $totalEntries,
            $totalRows,
            $currentPage,
            $totalPages,
        ]));

        $inputGroup->childNodes->push($addOn);

        $input = new Ui\Components\Form\Elements\Input([
            'name'        => 'page',
            'placeholder' => language()->getLine('TABLE_LABEL_GOTO'),
        ]);

        $inputGroup->childNodes->push($input);

        $pagination = new Ui\Components\Pagination($totalRows, $showEntries);
        $inputGroup->childNodes->push($pagination);

        $columnShow->childNodes->push($inputGroup);

        $card->textContent->push(parent::render());

        return $card->render();
    }
792534
function render(Frame $frame) {
    $style = $frame->get_style();
    
    if ( trim($frame->get_node()->nodeValue) === "" && $style->empty_cells === "hide" ) {
      return;
    }

    $this->_set_opacity( $frame->get_opacity( $style->opacity ) );
    list($x, $y, $w, $h) = $frame->get_border_box();
    
    // Draw our background, border and content
    if ( ($bg = $style->background_color) !== "transparent" ) {
      $this->_canvas->filled_rectangle($x, $y, $w, $h, $bg);
    }

    if ( ($url = $style->background_image) && $url !== "none" ) {
      $this->_background_image($url, $x, $y, $w, $h, $style);
    }
    
    $table = Table_Frame_Decorator::find_parent_table($frame);

    if ( $table->get_style()->border_collapse !== "collapse" ) {
      $this->_render_border($frame);
      $this->_render_outline($frame);
      return;
    }

    // The collapsed case is slightly complicated...
    // @todo Add support for outlines here

    $cellmap  = $table->get_cellmap();
    $cells    = $cellmap->get_spanned_cells($frame);
    $num_rows = $cellmap->get_num_rows();
    $num_cols = $cellmap->get_num_cols();

    // Determine the top row spanned by this cell
    $i = $cells["rows"][0];
    $top_row = $cellmap->get_row($i);

    // Determine if this cell borders on the bottom of the table.  If so,
    // then we draw its bottom border.  Otherwise the next row down will
    // draw its top border instead.
    if (in_array( $num_rows - 1, $cells["rows"])) {
      $draw_bottom = true;
      $bottom_row = $cellmap->get_row($num_rows - 1);
    } else
      $draw_bottom = false;


    // Draw the horizontal borders
    foreach ( $cells["columns"] as $j ) {
      $bp = $cellmap->get_border_properties($i, $j);

      $y = $top_row["y"] - $bp["top"]["width"] / 2;

      $col = $cellmap->get_column($j);
      $x = $col["x"] - $bp["left"]["width"] / 2;
      $w = $col["used-width"] + ($bp["left"]["width"] + $bp["right"]["width"] ) / 2;

      if ( $bp["top"]["style"] !== "none" && $bp["top"]["width"] > 0 ) {
        $widths = array($bp["top"]["width"],
                        $bp["right"]["width"],
                        $bp["bottom"]["width"],
                        $bp["left"]["width"]);
        $method = "_border_". $bp["top"]["style"];
        $this->$method($x, $y, $w, $bp["top"]["color"], $widths, "top", "square");
      }

      if ( $draw_bottom ) {
        $bp = $cellmap->get_border_properties($num_rows - 1, $j);
        if ( $bp["bottom"]["style"] === "none" || $bp["bottom"]["width"] <= 0 )
          continue;

        $y = $bottom_row["y"] + $bottom_row["height"] + $bp["bottom"]["width"] / 2;

        $widths = array($bp["top"]["width"],
                        $bp["right"]["width"],
                        $bp["bottom"]["width"],
                        $bp["left"]["width"]);
        $method = "_border_". $bp["bottom"]["style"];
        $this->$method($x, $y, $w, $bp["bottom"]["color"], $widths, "bottom", "square");

      }
    }

    $j = $cells["columns"][0];

    $left_col = $cellmap->get_column($j);

    if (in_array($num_cols - 1, $cells["columns"])) {
      $draw_right = true;
      $right_col = $cellmap->get_column($num_cols - 1);
    } else
      $draw_right = false;

    // Draw the vertical borders
    foreach ( $cells["rows"] as $i ) {
      $bp = $cellmap->get_border_properties($i, $j);

      $x = $left_col["x"] - $bp["left"]["width"] / 2;

      $row = $cellmap->get_row($i);

      $y = $row["y"] - $bp["top"]["width"] / 2;
      $h = $row["height"] + ($bp["top"]["width"] + $bp["bottom"]["width"])/ 2;

      if ( $bp["left"]["style"] !== "none" && $bp["left"]["width"] > 0 ) {

        $widths = array($bp["top"]["width"],
                        $bp["right"]["width"],
                        $bp["bottom"]["width"],
                        $bp["left"]["width"]);

        $method = "_border_" . $bp["left"]["style"];
        $this->$method($x, $y, $h, $bp["left"]["color"], $widths, "left", "square");
      }

      if ( $draw_right ) {
        $bp = $cellmap->get_border_properties($i, $num_cols - 1);
        if ( $bp["right"]["style"] === "none" || $bp["right"]["width"] <= 0 )
          continue;

        $x = $right_col["x"] + $right_col["used-width"] + $bp["right"]["width"] / 2;

        $widths = array($bp["top"]["width"],
                        $bp["right"]["width"],
                        $bp["bottom"]["width"],
                        $bp["left"]["width"]);

        $method = "_border_" . $bp["right"]["style"];
        $this->$method($x, $y, $h, $bp["right"]["color"], $widths, "right", "square");

      }
    }

  }
209471
def _render_content(self, content, **settings):
        
        result = []
        columns = settings[self.SETTING_COLUMNS]

        # Format each table cell into string.
        (columns, content) = self.table_format(columns, content)

        # Enumerate each table row.
        if settings[self.SETTING_FLAG_ENUMERATE]:
            (columns, content) = self.table_enumerate(columns, content)

        # Calculate the dimensions of each table column.
        dimensions = self.table_measure(columns, content)

        # Display table header.
        sb = {k: settings[k] for k in (self.SETTING_BORDER_STYLE, self.SETTING_BORDER_FORMATING)}
        result.append(self.fmt_border(dimensions, 't', **sb))
        if settings[self.SETTING_FLAG_HEADER]:
            s = {k: settings[k] for k in (self.SETTING_FLAG_PLAIN, self.SETTING_BORDER_STYLE, self.SETTING_BORDER_FORMATING)}
            s[self.SETTING_TEXT_FORMATING] = settings[self.SETTING_HEADER_FORMATING]
            result.append(self.fmt_row_header(columns, dimensions, **s))
            result.append(self.fmt_border(dimensions, 'm', **sb))

        # Display table body.
        for row in content:
            s = {k: settings[k] for k in (self.SETTING_FLAG_PLAIN, self.SETTING_BORDER_STYLE, self.SETTING_BORDER_FORMATING)}
            s[self.SETTING_TEXT_FORMATING] = settings[self.SETTING_TEXT_FORMATING]
            result.append(self.fmt_row(columns, dimensions, row, **s))

        # Display table footer
        result.append(self.fmt_border(dimensions, 'b', **sb))
        return result
859276
def render(self, namespace):
        '''
        '''
        ns = namespace.copy()
        result = []
        for item in namespace[self._items]:
            ns[self._item] = item
            result.append(self._block.render(ns))
        return '\n'.join(result) if result else None
759242
def render(*args, &block)
      captured = helpers.capture do
        helpers.concat(helpers.render(*args, &block))
        helpers.output_buffer.to_s
      end
      rawtext(captured)
    end
351704
public function render_table()
    {
        $ret = array();
        if (!is_array($this->args['table'])) {
            return;
        }
        foreach ($this->args['table'] as $row) {
            list($table, $alias) = $row;

            if (is_string($table)) {
                // table name passed as string
                $table = $this->bt($table);

            } elseif ($table instanceof DB_dsql) {
                // table passed as DSQL expression

                // remove SQL_CALC_FOUND_ROWS from subquery
                $i = @array_search('SQL_CALC_FOUND_ROWS', $table->args['options']);
                if ($i !== false) {
                    unset($table->args['options'][$i]);
                }

                // consume subquery
                $table = $this->consume($table);
            }

            if ($alias !== UNDEFINED && $alias) {
                $table .= ' '.$this->bt($alias);
            }

            $ret[] = $table;
        }

        return implode(',', $ret);
    }
398271
function renderTemplate(engine, filePath, content, context) {
    context = context || {};

    // Mutable objects to contains all blocks requiring post-processing
    var blocks = {};

    // Create nunjucks environment
    var env = engine.toNunjucks(blocks);

    // Replace shortcuts from plugin's blocks
    content = replaceShortcuts(engine.getBlocks(), filePath, content);

    return timing.measure(
        'template.render',

        Promise.nfcall(
            env.renderString.bind(env),
            content,
            context,
            {
                path: filePath
            }
        )
        .then(function(content) {
            return TemplateOutput.create(content, blocks);
        })
    );
}
492454
public function renderItems()
	{
		if ($this->json)
		{
			$renderedTableBody = $this->getRenderedTableBody();
			echo function_exists('json_encode')
				? json_encode($renderedTableBody)
				: CJSON::encode($renderedTableBody);
		}
		elseif ($this->dataProvider->getItemCount() > 0 || $this->showTableOnEmpty)
		{
			echo "<table class=\"{$this->itemsCssClass}\">\n";
			$this->renderTableHeader();
			$this->renderTableFooter(); // TFOOT must appear before TBODY according to the standard.
			$this->renderTableBody();
			echo "</table>";
			$this->renderTemplates();
		}
		else
		{
			$this->renderEmptyText();
		}
	}
257093
public function renderTableFooter()
	{
		$hasFilter = $this->filter !== null && $this->filterPosition === self::FILTER_POS_FOOTER;

		$hasFooter = $this->getHasFooter();
		if ($this->bulk !== null || $hasFilter || $hasFooter) {
			echo "<tfoot>\n";
			if ($hasFooter) {
				echo "<tr>\n";
				/** @var $column CDataColumn */
				foreach ($this->columns as $column) {
					$column->renderFooterCell();
				}
				echo "</tr>\n";
			}
			if ($hasFilter) {
				$this->renderFilter();
			}

			if ($this->bulk !== null) {
				$this->renderBulkActions();
			}
			echo "</tfoot>\n";
		}
	}
835794
public function renderTableHeader()
	{
		if(!$this->hideHeader)
		{
			echo "<thead>\n";

			if($this->filterPosition===self::FILTER_POS_HEADER)
				$this->renderFilter();

			echo "<tr>\n";
			foreach($this->columns as $column)
				$column->renderHeaderCell();
			echo "</tr>\n";

			if($this->filterPosition===self::FILTER_POS_BODY)
				$this->renderFilter();

			echo "</thead>\n";
		}
		elseif($this->filter!==null && ($this->filterPosition===self::FILTER_POS_HEADER || $this->filterPosition===self::FILTER_POS_BODY))
		{
			echo "<thead>\n";
			$this->renderFilter();
			echo "</thead>\n";
		}
	}
1363441
public function renderRows()
    {
        // precache template chunks
        $this->precacheTemplate();

        // extend CompleteLister renderRows method
        parent::renderRows();

        // if we have at least one data row rendered, then remove not_found message
        if ($this->total_rows) {
            $this->template->del('not_found');
        } elseif ($this->no_records_message) {
            $this->template->del('header');
            $this->template->set('not_found_message', $this->no_records_message);
        }
    }
7246
def render_table(output_dir, packages, jenv=JENV):
  
  destination_filename = output_dir + "/com/swiftnav/sbp/client/MessageTable.java"
  with open(destination_filename, 'w+') as f:
      print(destination_filename)
      f.write(jenv.get_template(TEMPLATE_TABLE_NAME).render(packages=packages))
1078443
public static function render() {
        self::newRow();
        ob_start();
        ?>

        <table <?php echo (!empty(self::$table_attributes)) ? self::parseAttributes(self::$table_attributes) : ""; ?>>
            <?php
            if (!empty(self::$headers)) {
                ?>

                <thead>
                    <tr>
                        <?php
                        foreach (self::$headers as $header) {
                            ?>

                            <th <?php echo self::parseAttributes($header[1]); ?>><?php echo $header[0] ?></th>
                            <?php
                        }
                        ?>

                    </tr>
                </thead>
                <?php
            }
            if (!empty(self::$rows)) {
                ?>

                <tbody>
                    <?php
                    foreach (self::$rows as $rowData) {
                        if (count($rowData) > 1) {
                            ?>

                            <tr <?php echo self::parseAttributes($rowData[0]); ?>>
                                <?php
                                foreach ($rowData[1] as $row) {
                                    ?>
                                    <td <?php echo self::parseAttributes($row[1]); ?>><?php echo $row[0] ?></td>
                                    <?php
                                }
                                ?>

                            </tr>
                            <?php
                        }
                    }
                    ?>

                </tbody>
                <?php
            }
            if (!empty(self::$footers)) {
                ?>

                <tfoot>
                    <tr>
                        <?php
                        foreach (self::$footers as $footer) {
                            ?>

                            <th <?php echo self::parseAttributes($footer[1]); ?>><?php echo $footer[0] ?></th>
                            <?php
                        }
                        ?>

                    </tr>
                </tfoot>
            <?php }
            ?>
        </table>
        <?php
        return ob_get_clean();
    }
116678
def _render_template_block_nodelist(nodelist, block_name, context):
    """"""

    # Attempt to find the wanted block in the current template.
    for node in nodelist:
        # If the wanted block was found, return it.
        if isinstance(node, BlockNode):
            # No matter what, add this block to the rendering context.
            context.render_context[BLOCK_CONTEXT_KEY].push(node.name, node)

            # If the name matches, you're all set and we found the block!
            if node.name == block_name:
                return node.render(context)

        # If a node has children, recurse into them. Based on
        # django.template.base.Node.get_nodes_by_type.
        for attr in node.child_nodelists:
            try:
                new_nodelist = getattr(node, attr)
            except AttributeError:
                continue

            # Try to find the block recursively.
            try:
                return _render_template_block_nodelist(new_nodelist, block_name, context)
            except BlockNotFound:
                continue

    # The wanted block_name was not found.
    raise BlockNotFound("block with name '%s' does not exist" % block_name)
963172
public function renderBlock($name, array $context, array $blocks = [], $useBlocks = true)
    {
        return $this->template->renderBlock($name, $context, $blocks, $useBlocks);
    }
140255
function replaceTable($table, tableData) {
  const cellIndexData = tableDataHandler.createCellIndexData(tableData);
  const renderData = tableDataHandler.createRenderData(tableData, cellIndexData);
  const $newTable = $(createTableHtml(renderData));

  $table.replaceWith($newTable);

  return $newTable;
}