Ver Mensaje Individual
  #11 (permalink)  
Antiguo 31/03/2015, 10:36
Avatar de Chiiviito
Chiiviito
 
Fecha de Ingreso: octubre-2012
Mensajes: 64
Antigüedad: 11 años, 6 meses
Puntos: 0
Respuesta: Necesito saber como ejecutar funcion desde TWIG

Hola si me di cuenta pero el error continua:
Código PHP:
<?php
require_once 'Twig/Autoloader.php';

Twig_Autoloader::register();

$loader = new Twig_Loader_Filesystem('templates');

$twig = new Twig_Environment($loader, array(
            
'cache' => 'cache',
            
'debug' => 'true'));

# Esta es mi funcion
//$twig = new Twig_Environment($loader); //Aca se declaa por segunda vez
$function = new Twig_SimpleFunction('function_name', function () {
    
// ...
});
$twig->addFunction($function);
/*----------------------------------*/
            
$template $twig->loadTemplate('index.twig.html');

echo 
$template->render(array());
Código PHP:
Fatal error: Class 'Twig_SimpleFunction' not found in ... 
Es como si la clase "Twig_SimpleFunction" no existiera.