Tutorial :Mako “Missing parentheses in %def”



Question:

In trying to add a cached section to a Mako template, I get the error 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>  


Solution:1

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.


Solution:2

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


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »