private function renderHtml(Element $element)
{
$output = '';
if ($this->getIndentationLevel() > 0) {
$output .= $this->getSpaces() . '<' . $element->getTag();
} else {
$output .= '<' . $element->getTag();
}
if ($element->useAttsHelper()) {
$output .= ' <?php atts(array(';
if (($atts = $element->getAttributes()) != null) {
if (isset($atts['id'])) {
$output .= "'id' => " . $this->_renderArrayValue($atts['id'], '_', 'php') . ', ';
unset($atts['id']);
}
if (isset($atts['class'])) {
$output .= "'class' => " . $this->_renderArrayValue($atts['class'], ' ', 'php') . ', ';
unset($atts['class']);
}
foreach ($atts as $name => $att) {
$output .= "";
switch ($att['t']) {
case 'str':
$interpolation = new Interpolation($att['v'], true);
$att_value = $interpolation->render();
$output .= "'{$name}' => {$att_value}, ";
continue;
case 'php':
if (is_array($att['v'])) {
$output .= "'{$name}' => array(" . join(',', $att['v']) . ')';
} else {
$output .= "'{$name}' => {$att['v']}, ";
}
continue;
case 'static':
$output .= "'{$name}' => '{$name}', ";
continue;
case 'function':
$output .= "{$att['v']}, ";
continue;
}
}
}
$output = rtrim($output, ', ');
$output .= ')); ?>';
} else {
if (($atts = $element->getAttributes()) !== null) {
if (isset($atts['id'])) {
$output .= ' id="' . $this->_renderArrayValue($atts['id'], '_', 'txt') . '"';
unset($atts['id']);
}
if (isset($atts['class'])) {
$output .= ' class="' . $this->_renderArrayValue($atts['class'], ' ', 'txt') . '"';
unset($atts['class']);
}
foreach ($atts as $name => $att) {
switch ($att['t']) {
case 'str':
$output .= " {$name}={$att['v']}";
continue;
case 'php':
$output .= " {$name}=<?php {$att['v']}; ?>";
continue;
case 'static':
$output .= " {$name}=\"{$name}\"";
continue;
}
}
}
}
$interpolation = new Interpolation($output);
$output = $interpolation->render();
if ($this->_el->isSelfClosing()) {
$output .= ' />';
} else {
// render inline content
$content = $this->renderTagContent($element->getInlineContent());
$output .= '>' . $content . '</' . $element->getTag() . '>';
}
return $output . "\n";
}