1. Go to this page and download the library: Download bugo/antlers-php 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/ */
bugo / antlers-php example snippets
use Bugo\Antlers\Engine;
$engine = new Engine();
echo $engine->render('Hello, {{ name }}!', ['name' => 'World']);
// → Hello, World!
$engine->setStrictMode(true);
echo $engine->render('{{ name }}', ['name' => 'Alice']);
// Alice
echo $engine->render('{{ missing }}');
// throws AntlersRuntimeException
$engine->render("<h1>{{ title }}</h1>\n<p>{{ missing }}</p>", ['title' => 'Home']);
// throws: Undefined variable: "missing" on line 2
$engine->setDebug(true);
echo $engine->render('{{ dump }}'); // dumps the current scope
echo $engine->render('{{ dump value=user }}'); // dumps a single value
use Bugo\Antlers\Support\MarkdownRendererInterface;
$engine->setMarkdownRenderer(new class implements MarkdownRendererInterface {
public function render(string $markdown): string
{
return my_own_parser($markdown);
}
});
use Bugo\Antlers\Support\CommonMarkRenderer;
use League\CommonMark\CommonMarkConverter;
$engine->setMarkdownRenderer(new CommonMarkRenderer(
new CommonMarkConverter(['html_input' => 'escape', 'max_nesting_level' => 10]),
));
bash
composer
antlers
{{ if true }}A{{ /foreach }} {{# Unexpected closing tag {{ /foreach }}, expected {{ /if }} #}}
{{ if true }}A {{# Unclosed tag {{ if }} #}}
{{ /if }} {{# Unexpected closing tag {{ /if }} #}}
antlers
{{ dump force="true" value=user }}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.