Tutorial :Mako “Missing parentheses in %def”


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>  


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

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