Unexpected token "name" of value "with" ("end of statement block" expected) in
来源:互联网 发布:时间机器字幕制作软件 编辑:程序博客网 时间:2024/05/16 19:41
在symfony2.3之后,不能使用 {% render "AcmeDemoBundle:Demo:fancy" with { 'name': name, 'color': 'green' } %}
应该使用 {{render(controller('AcmeDemoBundle:Demo:fancy',{ 'name': name, 'color': 'green'}))}}
{% render "AcmeDemoBundle:Demo:fancy" with { 'name': name, 'color': 'green' } %}
应该使用 {{render(controller('AcmeDemoBundle:Demo:fancy',{ 'name': name, 'color': 'green'}))}}
包含控制器的输出¶
那么如何在模板里嵌入另外的控制器(controller)的输出?在开发Ajax应用,或者被包含的模板引用了主模板里并不存在的变量时,这个特性就会变得十分有用。
假设你已经创建了一个fancy动作方法(action),打算将其输出包含在index模板里,可以通过使用render标签来实现:
{# src/Acme/DemoBundle/Resources/views/Demo/index.html.twig #}{% render "AcmeDemoBundle:Demo:fancy" with { 'name': name, 'color': 'green' } %}
AcmeDemoBundle:Demo:fancy字符串指代的是Demo控制器的fancy动作方法。name和color此时就代替了请求参数,用来执行对fancyAction的调用。
// src/Acme/DemoBundle/Controller/DemoController.phpclass DemoController extends Controller{ public function fancyAction($name, $color) { // create some object, based on the $color variable $object = ...; return $this->render('AcmeDemoBundle:Demo:fancy.html.twig', array( 'name' => $name, 'object' => $object )); } // ...}
在symfony2.3之后,不能使用 {% render "AcmeDemoBundle:Demo:fancy" with { 'name': name, 'color': 'green' } %}
应该使用 {{render(controller('AcmeDemoBundle:Demo:fancy',{ 'name': name, 'color': 'green'}))}}
- Unexpected token "name" of value "with" ("end of statement block" expected) in
- An unexpected token\"BEGIN-OF-STATEMENT".\Expected tokens may include: "<space>"
- unexpected end of file found in comment
- unexpected end of file found in comment
- expected declaration or statement at end of input
- 错误: expected declaration or statement at end of input
- error: expected declaration or statement at end of input
- error: expected declaration or statement at end of input----solved
- expected declaration or statement at end of input
- unexpected end of file
- Unexpected end of stream.
- syntax error near unexpected token 和 Linux Shell syntax error: unexpected end of file
- : gzip: stdin: unexpected end of file tar: Unexpected EOF in archive tar: Unexpected EOF in archive
- Parse error: syntax error, unexpected end of file in
- error RC2103 : unexpected end of file in string literal
- 程序中出现unexpected end of file in macro expansion
- fatal error C1071: unexpected end of file found in comment
- Resin#unexpected end of file in utf8 character解决过程
- SQL Server日期时间相关详解
- Hibernate配置文件
- Solaris环境上性能分析工具:Oracle Solaris Studio 12.2:性能分析器
- 动软生成的GetListByPage行数的算法
- HDU--2004 -- 成绩转换
- Unexpected token "name" of value "with" ("end of statement block" expected) in
- [php]通过http post发送json数据
- oracle11g客户端+PlsqlDeveloper连接远程oracle服务器方法
- 利用WNet系列函数枚举和映射网络资源
- struts2 spring集成时struts.xml文件中action的class属性值意义
- C或C++中函数的参数传递包括:值传递、指针传递、引用传递
- linux入门
- 在eclipse中将android项目生成apk并且给apk签名
- 对iOS系统键盘的hack以及注意事项