PHP code example of swiftly / template

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

    

swiftly / template example snippets


 // hi.php 



use Swiftly\Template\FileFinder;
use Swiftly\Template\Engine;

$templates = new FileFinder("path/to/template/dir");
$renderer = new Engine($templates);

// $output -> "Hello world!"
$output = $renderer->render("hi.php");

 // template.php 



use Swiftly\Template\FileFinder;
use Swiftly\Template\Engine;

$templates = new FileFinder("path/to/template/dir");
$renderer = new Engine($templates);

// $output -> "My name is Douglas and I am 42 years old."
$output = $renderer->render("template.php", [
    "name" => "Douglas",
    "age" => 42
]);