Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
// Datos view Template
//Load lib
//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