1. Go to this page and download the library: Download burntcaramel/glaze library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
burntcaramel / glaze example snippets
use BurntCaramel\Glaze;
use BurntCaramel\Glaze\Prepare as GlazePrepare;
use BurntCaramel\Glaze\Serve as GlazeServe;
GlazeServe::element('h1#siteTitle', 'Title');
// No need to escape the &
GlazeServe::element('h2.tagline', 'The home of examples & more');
GlazeServe::element('p.any.classes.you.need', 'Blah blah blah blah');
/* Displays: */
GlazeServe::element(array(
'tagName' => 'meta',
'name' => 'description',
'content' => 'Site description as seen by search engines'
));
/* Displays: */
$classNames = array('post');
if (isArticle()):
$classNames[] = 'article';
if (isFeatureArticle()):
$classNames[] = 'feature';
endif;
endif;
// The -Checking method makes sure that if `$classNames` is empty, then nothing will be displayed.
$info = array(
'itemID' => 'fddf3tq3tt3t3',
'published' => false,
'genreIdentifier' => 'thriller',
'salesCount' => 56,
'selected' => true,
'authorName' => 'John Smith',
'itemDescription' => array(
'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',
'Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.',
'Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.'
)
);
// Build a list of classes using an array, don't fuss with appending to a string
$classNamesArray = array('item', 'book');
$classNamesArray[] = !empty($info['published']) ? 'published' : 'upcoming';
$classNamesArray[] = 'genre-' .$info['genreIdentifier']; // e.g. 'genre-thriller'
$bookItemDiv = GlazePrepare::element('div');
{
$bookItemDiv->setAttribute('id', "bookItem-{$info['itemID']}");
// Lets you use an array of strings for class attributes.
$bookItemDiv->addClassNames($classNamesArray);
// Only display the attribute if variable reference $info['salesCount'] is present.
$bookItemDiv->setAttributeChecking('data-sales-count', $info['salesCount']);
$bookItemDiv->setAttributeChecking('data-sales-count-nope', $info['salesCount_NOPE']);
// Only displays the attribute, with the value 'selected', if $info['selected'] is true.
$bookItemDiv->setAttributeChecking('selected', $info['selected'], 'selected');
$bookItemDiv->setAttributeChecking('selected-nope', $info['selected_NOPE'], 'selected');
// Will display:
$bookItemDiv->appendNewElement('h5.authorName',
Glaze\check($info['authorName'])
);
// Will not display, as key 'authorName_NOPE' does not exist.
$bookItemDiv->appendNewElement('h5.authorName',
Glaze\check($info['authorName_NOPE'])
);
// Will display:
$bookItemDiv->appendNewElement('p.description',
GlazePrepare::contentSeparatedBySoftLineBreaks(
Glaze\check($info['itemDescription'])
)
);
// Will not display, as key 'itemDescription_NOPE' does not exist.
$bookItemDiv->appendNewElement('p.description',
GlazePrepare::contentSeparatedBySoftLineBreaks(
Glaze\check($info['itemDescription_NOPE'])
)
);
}
$bookItemDiv->serve();