Ver Mensaje Individual
  #24 (permalink)  
Antiguo 31/03/2015, 17:30
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

Ahi ya no me salio ese error, que tarado nunca me fije al fecha ya actualice la version del Twig que tenia pero ahora nose como mandar la funcion mediante el array:


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'));
/*-----*/
$function = new Twig_SimpleFunction('fnx_asd', function () {
    return 
'La funcion salio bien!!';
});
$twig->addFunction($function);
/*-----*/
$template $twig->loadTemplate('index.twig.html');

echo 
$template->render(array(
    
'variable'    =>    'Hola mundo!',
    ));