Reference a static template in symfony2

点点圈 提交于 2019-12-01 09:22:32

问题


I want to use angular with symfony2. To do so it should be possible to load a template from a reference like this:

<div ng-include="/link/to/template.html"></div>

The loading is the part of angular. We just have to provide a path to the template. The template should not be rendered with twig. Is this possible with symfony?


回答1:


Simple make a template without twig tags, and a route for it to load via ajax. No controller is required

my_template:
    path: /path/to/template
    defaults:
        _controller: FrameworkBundle:Template:template
        template: 'AcmeBundle:Angular:template.html.twig'

More infos: http://symfony.com/doc/current/cookbook/templating/render_without_controller.html



来源:https://stackoverflow.com/questions/18081845/reference-a-static-template-in-symfony2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!