Exemple #1
0
$classNamesArray[] = !empty($info['published']) ? 'published' : 'upcoming';
$classNamesArray[] = 'genre-' . $info['genreIdentifier'];
// e.g. 'genre-thriller'
// Begin the <div>
$bookItemDiv = glazyBegin('div');
glazyAttribute('id', "bookItem-{$info['itemID']}");
// Lets you use an array of strings for class attributes.
glazyAttribute('class', $classNamesArray);
// Only display the attribute if variable reference $info['salesCount'] is present.
glazyAttributeCheck('data-sales-count', $info['salesCount']);
glazyAttributeCheck('data-sales-count', $info['salesCount_NOPE']);
// Only displays the attribute, with the value 'selected', if $info['selected'] is true.
glazyAttributeCheck('selected', $info['selected'], 'selected');
glazyAttributeCheck('selected-nope', $info['selected_NOPE'], 'selected');
glazyElement('h5.authorName', glazyCheckContent($info['authorName']));
glazyElement('p.description', glazyPrepareContentJoinedByLineBreaks(glazyCheckContent($info['itemDescription'])));
glazyElement('p.description', glazyPrepareContentJoinedByLineBreaks(glazyCheckContent($info['itemDescription_NOPE'])));
// Finish and close the </div>
glazyFinish($bookItemDiv);
glazyElement('h2', 'These are already escaped &amp; &lt; &gt;', GLAZE_TYPE_PREGLAZED);
$img = glazyBegin('img');
glazyAttribute('src', 'http://placehold.it/150x50');
$escapedText = 'Bangers &amp; Mash';
glazyAttribute('alt', $escapedText, GLAZE_TYPE_PREGLAZED);
glazyFinish($img);
glazyElement('hr');
glazyElement('p', array('Updating this file by using: ', glazyPrepareElement('br'), glazyPrepareElement('code', 'php -f example-update.php')));
glazyElement('p', array('Check this file with the last version by using: ', glazyPrepareElement('br'), glazyPrepareElement('code', 'php -f example-check.php')));
glazyElement('p', array('You can download glaze.php from here: ', glazyPrepareElement(array('tagName' => 'a', 'href' => 'http://github.com/BurntCaramel/glaze'), 'github.com/BurntCaramel/glaze')));
glazyFinish($body);
glazyFinish($html);
Exemple #2
0
function glazyBegin($tagNameOrElementOptions, $contentType = GLAZE_TYPE_PREGLAZED)
{
    global $glazyOpenElements;
    glazyEnsureOpeningTag();
    $elementInfo = glazyPrepareElement($tagNameOrElementOptions);
    $tagName = $elementInfo['tagName'];
    $attributes = $elementInfo['attributes'];
    echo "<{$tagName}";
    glazyBeginAttributesBufferIfNeeded();
    if (!isset($glazyOpenElements)) {
        $glazyOpenElements = array();
    }
    $openElementsCountBefore = count($glazyOpenElements);
    if (empty($glazyOpenElements)) {
        ob_start();
    } else {
        ob_start();
    }
    $glazyOpenElements[] = array('tagName' => $tagName, 'openingTagDone' => false, 'contentType' => $contentType);
    if (!empty($attributes)) {
        glazyAttributesArray($attributes);
    }
    // Return info for glazyFinish.
    return array('_glazyBegin_' => true, 'tagName' => $tagName, 'previousOpenElementsCount' => $openElementsCountBefore);
}