Haanga包含带参数的模板

时间:2016-12-29 09:41:41

标签: php html django templates include

在Django中,您应该能够做到这样的事情:

{% include "fragments/threadComment.html" with post.comments as comment only %}

但我们正在使用基于Django的Haanga女巫,当我遇到Haanga的一些问题时,我被告知要遵循Django文档,但我不能让这部分工作。

这是否在Haanga中得到支持?

我收到此错误:

  

致命错误:未捕获Haanga_Compiler_Exception:Haanga_Compiler_Exception:/ var / www / project / framework / lib / haanga / Compiler /中的/var/www/project/templates//pages/postThread.html:5中出现意外的T_WITH(with) Parser.php:155堆栈跟踪:#0 /var/www/project/framework/lib/Haanga/Compiler/Parser.php(2253):Haanga_Compiler_Parser->错误('意外的T_WI ......')#1 / var /www/project/framework/lib/Haanga/Compiler/Parser.php(2364):Haanga_Compiler_Parser-> yy_syntax_error(36,'with')#2 / var / www / project / framework / lib / Haanga / Compiler / Tokenizer .php(570):Haanga_Compiler_Parser-> doParse(36,'with')#3 /var/www/project/framework/lib/Haanga/Compiler.php(256):Haanga_Compiler_Tokenizer :: init('{%extends“ bas ...',Object(Haanga_Compiler_Runtime),'/ var / www / projec ...')#4 /var/www/project/framework/lib/Haanga/Compiler.php(356):Haanga_Compiler->编译('{%extends“bas ...','/ var / www / projec ...','/ var / www / projec ...')#5 / var / www / project / framework / lib / Haanga .php(378):Haanga_Compiler->编译_file('/ var / www / projec ...',false,Array)#3 / var / www in /var/www/project/framework/lib/Haanga/Compiler.php on line 399

1 个答案:

答案 0 :(得分:0)

我从未使用过Haanga,但在Django中,将变量传递给包含模板的语法是with varname=value,而不是with value as varname

所以试试:

{% include "fragments/threadComment.html" with comment=post.comments only %}