Download the PHP package younishd/endobox without Composer
On this page you can find all versions of the php package younishd/endobox. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package endobox
endobox
minimal template engine.
:seedling: Native PHP syntax | :pencil: Markdown on-board | :rocket: Minimal API |
---|---|---|
Write templates in vanilla PHP. No need to learn a new syntax. | A full-blown Markdown parser is built right in. Yes, it can be combined with PHP! | Do powerful things with just a handful of elementary methods. |
Documentation
- Installation
- Get started
- Render templates
- File extensions
- Data
- Chaining & Nesting
- Functions
- Cloning
Installation
Install endobox is via Composer:
You will need PHP 7.0+.
Get started
The typical way to configure endobox to load templates for an application looks like this:
You can add additional template locations:
Render templates
Instantiate a Box
for your template:
Render the template with some variables by calling render()
:
The template file itself could look like this:
welcome.php
File extensions
endobox decides how to render a template based on the file extension.
When you instantiate the template Box
however, the extension is omitted.
PHP: .php
PHP templates are processed by evaluating the code between PHP tags (i.e., <? … ?>
) and returning the result.
members.php
:information_source: Protip: The
<?=
is syntactic sugar for</article>
| |$markdown()
or$m()
|Render some text as Markdown. Useful when the text is user input/stored in a database.|<?= $markdown('This is some _crazy comment_!') ?>
| |$escape()
or$e()
|Sanitize unsafe user input usinghtmlspecialchars()
. (See Escaping.)|<img src="portrait.jpg" alt="<?= $e($name) ?>">
|
Cloning
You can easily clone a template Box
using the built-in clone
keyword.
The cloned box will have the same content and data as the original one. However, chained or linked boxes are discarded.
License
endobox is open-sourced software licensed under the MIT license.