What is the difference between using .html.twig and .twig? Is there some kind of standard, is it framework specific, or is it just user preference?
Under Symfony you have the possibility to deliver different formats automatically. So you can create files like test.json.twig
, test.xml.twig
for example. If you define all that extensions in your controller you can deliver all that formats under one action.
For example:
/**
* @Route("/hello/{name}.{_format}", defaults={"_format"="html"}, name="_demo_hello")
* @Template()
*/
public function helloAction($name) {
return array('name' => $name);
}
Something like this. So you can use the format in your route to define the response format.
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