I am using routing by annotations and this is what my controller has:
/** * @Route("/", name="_index") * @Template() */
I understand routes but can someone explain what @Template() is doing there and how can I use it? I could not find any documentation about this.
Thanks...
The @Template annotation associates a controller with a template name:
More info here: http://symfony.com/doc/2.0/bundles/SensioFrameworkExtraBundle/annotations/view.html
In addition to this answer (btw, is correct). You should add the suffix ".html.twig" in case you're using the TWIG engine to render the templates.
Your should look like this
/**
* @Template("MyOwnBundle:Default:myOwnView.html.twig")
*/
public function showAction()
{
... bla bla bla
... more bla bla
}
In this case, you're forcing the showAction() to use a custom template. If the @Template() is empty, your showAction() will looking for the associated template by convention.
Hope this helps.. if not, only "decorates" a little bit more the answer.
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