PHP code example of aatis / template-renderer

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

    

aatis / template-renderer example snippets


// Directly in PHP code when building the container :

(new ContainerBuilder($ctx))
    ->register(TemplateRenderer::class)
    ->build();

$templateRenderer->render('path/to/template', [
    'var_name' => 'value'
]);

class ExtraRenderer extends AbstractTemplateRenderer
{
    public const EXTENSION = '.tpl.extra';

    public function render(string $template, array $vars = []): string
    {
        // Transform the special extension type template into a string
    }
}

class ExtraRenderer extends AbstractTemplateRenderer
{
    public const EXTENSION = '.tpl.extra';

    public function render(string $template, array $vars = []): string
    {
        // do some stuff
        $content = $this->getTemplateContent($template, $vars);
        // do some stuff and return the content
    }
}