PHP code example of vanilla / ebi
1. Go to this page and download the library: Download vanilla/ebi 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/ */
vanilla / ebi example snippets
$ebi = new Ebi(...);
$ebi->setMeta('title', 'Welcome to the Page');
$ebi->write(...);
if (empty($props['items'])) {
echo "<p>There are no items!</p>";
}
if ($props['signedIn']) {
echo '<div>Welcome!</div>';
} else {
echo '<div>Sign in to participate.</div>';
}
echo '<ul>';
foreach ($props['people'] as $props1) {
echo 'Hi ',
$this->escape($props1['firstName']),
' ',
$this->escape($props1['lastName']);
}
echo '</ul>';
echo '<ul>';
foreach ($props['comments'] as $i1 => $props1) {
echo '<li>',
$this->escape($props['name']),
': ',
$this->escape($props1['body']),
' #',
$this->escape($i1)
'</li>';
}
echo '</ul>';
echo '<ul>';
$count1 = count($props);
$index1 = -1;
foreach ($props as $i1 => $props1) {
$index1++;
$first1 = $index1 === 0;
$last1 = $index1 === $count1 - 1;
echo '<li',
$this->attribute('id', $i1),
$this->attribute('data-index', $index1),
$this->attribute('class', $this->attributeClass(array("first" => $first1, "last" => $last1))),
'>',
$this->escape($props1),
'</li>';
}
echo '</ul>';
echo '<ul>';
if (empty($props['messages'])) {
echo '<li>There are no messages.</li>';
} else {
foreach ($props['message'] as $i1 => $props1) {
echo '<li>',
$this->escape($props1['body']),
'</li>';
}
}
echo '</ul>';
$props1 = $props['user'];
echo '<div>',
'Hello ',
$this->escape($props1['name']),
'</div>';
$props1 = trim(ucfirst($props['sentence']));
if (!empty($props1)) {
echo $this->escape($props1);
}
echo '<code>Hello <b x-literal>{username}</b></code>';
echo '<h'.$props['level'].'>',
$this->escape($props['heading']),
'</h'.$props['level'].'>';
echo $this->escape(join('|', [1, 2, 3]);
echo join('>', [1, 2, 3]);
$title = trim(ucfirst($props['sentence']));
if (!empty($title) {
echo '<h1>',
$this->escape($title),
'</h1>';
}
if ($props['signedIn']) {
echo 'Welcome back';
}
$this->register('long-date', function ($props) {
echo '<time datetime="',
htmlspecialchars(date($props['date'], 'c')),
'">',
htmlspecialchars(date($props['date'], 'r')),
'</time>';
});
$this->render('long-date', ['date' => $props['dateInserted']]);
$this->register('hello', function ($props) {
echo 'Hello ',
$this->escape($props['name']);
});
$this->register('goodbye', function ($props) {
echo 'Goodbye ',
$this->escape($props['name']);
});
$this->write($props['salutation'], $props);
function ($props) {
// Do something.
echo '<p>wut!?</p>';
};
$ebi = new Ebi(
new FilesystemLoader('/path/to/templates'),
'/path/to/cache'
);
$ebi->write('component', $props);
html
<p>Hello {user.firstName} {user.lastName}.</p>