mako如何访问Windows下当前正在渲染的对象名称

发布于 2024-11-19 18:50:58 字数 662 浏览 8 评论 0原文

我是 Mako 新手,对对象模型有疑问。

我们在 Windows 7 下通过 render 命令通过 mako 生成一个模板文件,类似于

out.write(self.objectname.render(...))

正在渲染的文件中,我想访问类似于以下伪代码的对象名...

<%namespace name="mapping" module="objtool.mapping" />
<%!
import os
import time
%>\
======================================================
== this file is being rendered from $(object.name)
======================================================

这可能吗?

注意:我可以让它生成类似于以下内容的输出

this file is being rendered from <mako.template.Template object at 0x02F48990>

,但我想要实际的对象名称

I am new to mako, and have a question about the object model.

We are generating a template file via mako under Windows 7 through the render command, similar to

out.write(self.objectname.render(...))

within the file being rendered, I want to access the objectname similar to the following pseudo code ...

<%namespace name="mapping" module="objtool.mapping" />
<%!
import os
import time
%>\
======================================================
== this file is being rendered from $(object.name)
======================================================

Is this even possible?

Note: I can get it to generate output similar to the following

this file is being rendered from <mako.template.Template object at 0x02F48990>

but I want the actual object name

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

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

发布评论

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

评论(1

偏爱你一生 2024-11-26 18:50:58
<%namespace name="mapping" module="objtool.mapping" />
<%!
import os
import time
%>\
======================================================
== this file is being rendered from ${os.path.basename(self.name)}
======================================================

渲染

======================================================
== this file is being rendered from poco_custom.cs
======================================================
<%namespace name="mapping" module="objtool.mapping" />
<%!
import os
import time
%>\
======================================================
== this file is being rendered from ${os.path.basename(self.name)}
======================================================

renders

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