[英]Twig write from Yaml file
我有这个问题:我的Yaml文件:
locale: en
codes:
button.cancel: Cancel
button.accept: Accept
radio.male: Male
radio.female: Female
我需要将所有yaml文件写入页面
控制器动作:
/**
* @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,
));
}
我的树枝文件:
{% for file in files %}
{% for key,value in file %}
{{key}}: {{value}}<br>
{% endfor %}
{% endfor %}
我的浏览器的答案是
button.cancel: Cancel
button.accept: Accept
radio.male: Male
radio.female: Female
而且我需要我所有的yaml文件谢谢您的帮助
OK,我解决了这是树枝文件:
locale: {{files["locale"]}}<br>
codes:<br>
{% for file in files %}
{% for code,value in file %}
{{code}}: {{value}}<br>
{% endfor %}
{% endfor %}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.