PHP code example of piotr-cz / twig-extensions-joomla

1. Go to this page and download the library: Download piotr-cz/twig-extensions-joomla 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/ */

    

piotr-cz / twig-extensions-joomla example snippets


// Configure Twig
$loader = new \Twig_Loader_Filesystem(JPATH_TEMPLATES);
$twig = new \Twig_Environment($loader, $options = array());

// Register Extension
$twig->addExtension(new \TwigJoomla\Extension\TextExtension);

// Render Template
$template = $twig->loadTemplate('test.twig');
echo $template->render();

$twig->addExtension(new \Twigoomla\Extension\DateExtension($config->get('timezone')));
twig
{{ "HELLOW" | jtext('sprintf', 'World') }}
ini
SUNDAY		="neděle"
JUNE		="červen"