1. Go to this page and download the library: Download superruzafa/template 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/ */
superruzafa / template example snippets
php
$replacements = array(
'variable' => 'replacement'
);
$string = 'this string contains a {{ variable }}';
$template = new StringTemplate($string);
echo $template->render($replacements);
// 'this string contains a replacement'
php
$replacements = array(
'vehicle' => 'car',
'color' => 'dark gray'
);
$array = array(
'My {{ vehicle }} color is {{ color }}',
'Because {{ color }} is my favourite color',
'I also likes the {{ alternative-color }} color'
);
$template = new ArrayTemplate($array);
var_dump($template->render($replacements));
// array(
// 'My car color is dark gray',
// 'Because dark gray is my favourite color',
// 'I also likes the color'
// );
php
$array = array(
'vehicle' => 'bicycle',
'color' => 'blue',
'phrase' => 'My {{ vehicle }} color is {{ color }}',
);
$template = new ArrayTemplate($array);
var_dump($template->render());
// array(
// 'vehicle' => 'bicycle',
// 'color' => 'blue',
// 'phrase' => 'My bicycle color is blue',
// )
php
$love_triangle = array(
'me' => 'I like {{ you }}',
'you' => 'You like {{ she }}',
'she' => 'She likes {{ me }}'
);
$template = new ArrayTemplate($love_triangle);
var_dump($template->render());
// Warning: Cyclic recursion: you -> she -> me -> you in ...
// Warning: Cyclic recursion: she -> me -> you -> she in ...
// Warning: Cyclic recursion: me -> you -> she -> me in ...
// array(
// 'me' => 'I like You like She likes I like ',
// 'you' => 'You like She likes I like You like ',
// 'she' => 'She likes I like You like She likes '
// )
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.