开发者

Mako "Missing parentheses in %def"

开发者 https://www.devze.com 2022-12-28 12:21 出处:网络
In trying to add a cached section to a Mako template, I get the erro开发者_JAVA百科r listed in the above question. Adding () to the end gets rid of the error, but I see no content on my page. Any help

In trying to add a cached section to a Mako template, I get the erro开发者_JAVA百科r listed in the above question. Adding () to the end gets rid of the error, but I see no content on my page. Any help is appreciated!

<%def name="test" cached="True" cache_timeout="60" cache_type="file">
    Test
/%def>


My problem was that I was not aware that <%def> defines a function. If I use the parenthesis and call the function via ${test()} right after definition, it works as expected.


Shouldn't you be using parantheses while defining the def test. Also if the "cached" etc. are parameters then I think your your definition should be something like below:

<%def name="test(cached='True',cache_timeout='60',cache_type='file')"> 
    Test 
/%def> 

Also see the Mako documentation

0

精彩评论

暂无评论...
验证码 换一张
取 消