Skip to content

Instantly share code, notes, and snippets.

@EOM
Last active December 28, 2015 01:59
Show Gist options
  • Save EOM/7424686 to your computer and use it in GitHub Desktop.
Save EOM/7424686 to your computer and use it in GitHub Desktop.
// Datos view Template
$data=array(
//...
);
//Load lib
require_once'libs/Twig/Autoloader.php';
Twig_Autoloader::register();
//config path template
$loader = new Twig_Loader_Filesystem($pathTmp);
// Set path cache
$twig = new Twig_Environment($loader, array(
'cache' => false,
//'cache' => $pathNewsLetters.'tmp',
'debug' => true
));
// Con esto podemos tener la funcion base64_encode y base64_decode dentro del template
$twig->addFilter(new Twig_SimpleFilter('ebase64', 'base64_encode'));
$twig->addFilter(new Twig_SimpleFilter('dbase64', 'base64_decode'));
// Para llamarlo a la funciones desde dentro del templeta de Twig
// TemplateDemo.html.twig
// {{ varX|ebase64}}
// {{ varX|dbase64}}
$twig->render('TemplateDemo.html.twig', $data);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment