1. Go to this page and download the library: Download abivia/penknife 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/ */
abivia / penknife example snippets
$engine = new \Abivia\Penknife\Penknife();
echo $engine->format(
'{{first}} {{last}}', function (string $expression, $type) {
return match ($expression) {
'first' => 'Jane',
'last' => 'Doe',
};
});
);
$template = "looping:\n{{@list}}index {{loop.#}} line {{loop1.#.1}} value {{loop}}\n{{/@list}}";
$engine = new \Abivia\Penknife\Penknife();
echo $engine->format($template, function ($expr) {
return $expr === 'list' ? ['first' => 'one', 'second' => 'two'] : null;
});
$engine = new \Abivia\Penknife\Penknife();
// Note the spaces in the if and else tokens
$engine->setTokens([
'open' => '<**<',
'close' => '>**>',
'if' => 'if ',
'else' => 'else ',
'end' => '~',
]);
// This is now a valid template:
$template = "conditional:<**<if test>**>TRUE<**<else if test>**>FALSE<**<~if test>**>."
{{?variable}}
true part
{{!?variable}}
Optional false part
{{/?variable}}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.