gpt4 book ai didi

python - 在 Mako 中捕获 body 内容?

转载 作者:行者123 更新时间:2023-11-28 22:04:17 25 4
gpt4 key购买 nike

是否可以从 Mako 模板中获取渲染的正文内容?我的意思是我可以使用 ${self.body()} 显示正文,但是如果我想先对它做些什么呢?

最佳答案

显然我要找的是 capture function .来自文档:

The other way to buffer the output of a def or any Mako callable is by using the built-in capture function. This function performs an operation similar to the above buffering operation except it is specified by the caller.

${" results " + capture(somedef) + " more results "}

或者在我的例子中:

<%
body = capture(self.body)
# etc.
%>

关于python - 在 Mako 中捕获 body 内容?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7479572/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com