在 symfony2 中引用静态模板 [英] Reference a static template in symfony2

查看:27
本文介绍了在 symfony2 中引用静态模板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在 symfony2 中使用 angular.为此,应该可以从这样的引用加载模板:

加载是角度的一部分.我们只需要提供模板的路径.模板不应该用树枝渲染.symfony 可以做到这一点吗?

解决方案

简单地制作一个没有 twig 标签的模板,以及一个通过 ajax 加载的路由.不需要控制器

my_template:路径:/路径/到/模板默认值:_controller: FrameworkBundle:Template:template模板:'AcmeBundle:Angular:template.html.twig'

更多信息:http://symfony.com/doc/current/cookbook/templating/render_without_controller.html

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?

解决方案

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

这篇关于在 symfony2 中引用静态模板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆