Mako“%def 中缺少括号”

发布于 2024-08-30 11:11:45 字数 215 浏览 2 评论 0原文

在尝试将缓存部分添加到 Mako 模板时,我收到上述问题中列出的错误。在末尾添加 () 可以消除错误,但我在页面上看不到任何内容。任何帮助表示赞赏!

<%def name="test" cached="True" cache_timeout="60" cache_type="file">
    Test
/%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>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

一梦等七年七年为一梦 2024-09-06 11:11:45

我的问题是我不知道 <%def> 定义了一个函数。如果我使用括号并在定义后立即通过 ${test()} 调用该函数,它将按预期工作。

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.

浮萍、无处依 2024-09-06 11:11:45

您在定义 def 测试时不应该使用括号吗?
另外,如果“缓存”等是参数,那么我认为你的
您的定义应如下所示:

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

另请参阅 Mako 文档

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文