PHP code example of activecollab / templateengine

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

    

activecollab / templateengine example snippets


$template_engine = new PhpTemplateEngine('/path/to/templates/dir');

// Set attributes that will be passed to all templates. Method chaining is supported.
$template_engine->setAttributes([
    'app_name' => 'My Awesome App',
    'app_version' => '1.0.0',
])->addAttribute('app_env', 'staging');

// Render template to output buffer
$template_engine->display('/mail/hello.php', ['first_name' => 'John'])

// Render template and return output as a string
$output = $template_engine->fetch('/mail/hello.php', ['first_name' => 'John'])

$template_engine->fetch('/example/../../../../etc/passwd'); // Will throw an exception