Example #1
0
function &glazyEnsureOpeningTag()
{
    $glazyOpenElements =& glazyGetOpenElements();
    if (empty($glazyOpenElements)) {
        // Return by reference is pretty bad
        // but only way I can think to structure this
        // without classes.
        // Means we have to jump through hoops like this:
        $empty = null;
        return $empty;
    }
    $latestOpenElement =& $glazyOpenElements[count($glazyOpenElements) - 1];
    if (!$latestOpenElement['openingTagDone']) {
        echo glazyCopyAndCleanElementsBuffer();
        echo '>';
        if (glazeElementTagAddNewLineAfterOpening($latestOpenElement['tagName'])) {
            echo "\n";
        }
        $latestOpenElement['openingTagDone'] = true;
    }
    return $latestOpenElement;
}
Example #2
0
function glazyServeElement($preparedElement)
{
    if (empty($preparedElement)) {
        return;
    }
    $tagName = $preparedElement['tagName'];
    $attributes = $preparedElement['attributes'];
    glazyEnsureOpeningTag();
    echo "<{$tagName}";
    if (!empty($attributes)) {
        glazyAttributesArray($attributes);
    }
    echo '>';
    if (glazeElementTagAddNewLineAfterOpening($tagName)) {
        echo "\n";
    }
    $innerPreparedInfo = $preparedElement['innerPreparedInfo'];
    if (isset($innerPreparedInfo)) {
        glazyServe($innerPreparedInfo);
    }
    if (!glazeElementTagNameIsSelfClosing($tagName)) {
        echo "</{$tagName}>";
    }
    if (glazeElementTagAddNewLineAfterClosing($tagName)) {
        echo "\n";
    }
}