require_once './lib/Twig/Autoloader.php';
Twig_Autoloader::register();
$loader = new Twig_Loader_Filesystem('./');
$twig = new Twig_Environment($loader, array(
'cache' => false,
));
$data = array(
'name' => 'trololo',
'asdf' => array(
'nested' => 'value',
'and' => array(
'another' => 'deeply',
'nested' => 'structure'
)
),
'foo' => 'bar'
);
$bindings = array(
'test' => $data,
'data' => var_export($data, true)
);
$template = $twig->loadTemplate('options.twig');
//$string = $template->render($bindings);
$template->display($bindings);options.twig:
{{ data | raw }}gives:
array (
'name' => 'trololo',
'asdf' =>
array (
'nested' => 'value',
'and' =>
array (
'another' => 'deeply',
'nested' => 'structure',
),
),
'foo' => 'bar',
)
instead of what I need:
array (
'name' => 'trololo',
'asdf' =>
array (
'nested' => 'value',
'and' =>
array (
'another' => 'deeply',
'nested' => 'structure',
),
),
'foo' => 'bar',
)
Or on a sidenote: How to do recursive indentation with blocks or macros or loops?