I have this problem: My yaml file:
locale: en
codes:
button.cancel: Cancel
button.accept: Accept
radio.male: Male
radio.female: Female
I need to write all of yaml file into my page
controller action:
/**
* @Route("/read/")
* @Template()
*/
public function readAction()
{
$yaml = new Parser();
$file = $yaml->parse(file_get_contents(getcwd() .'/file.yml'));
return $this->render('AnyoneYamlGeneratorBundle:GenerateController:read.html.twig', array(
'files' => $file,
));
}
my twig file:
{% for file in files %}
{% for key,value in file %}
{{key}}: {{value}}<br>
{% endfor %}
{% endfor %}
answer of my browser is
button.cancel: Cancel
button.accept: Accept
radio.male: Male
radio.female: Female
and i need all of my yaml file Thanks for help
OK i solved this is twig file:
locale: {{files["locale"]}}<br>
codes:<br>
{% for file in files %}
{% for code,value in file %}
{{code}}: {{value}}<br>
{% endfor %}
{% endfor %}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With