PHP code example of billitech / sly

1. Go to this page and download the library: Download billitech/sly 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/ */

    

billitech / sly example snippets


//place at the top of your script
use Billitech\Sly\Sly;
use Billitech\Sly\FileLoader;
$loader = new FileLoader(['/path/to/your/templates']);
$sly = new Sly($loader, '/path/to/store/compiled_files');

echo $sly->render('index.sly', ['title' => 'Sly Template Ingine']);

$sly = new Sly($loader);

$sly->setCharset('utf8'); // Set the character encoding of your templates.
$sly->enableAutoEscape(); // Enable auto escape. 
$sly->disableAutoEscape(); // Disable auto escape.
$sly->enableStrictVariables(); // Enable strict variable.
$sly->disableStrictVariables(); // Disable strict variable.

$sly->render('users.sly', ['users' => ['foo', 'bar', 'barz'], 'title' => 'My Users']);