Pylons 中 Mako 模板中当前页面的 URL

发布于 2024-08-31 00:33:34 字数 132 浏览 3 评论 0原文

我需要从 Pylons 中的 Mako 模板文件中了解当前页面的完整 url。

该 url 将在页面内包含的 iframe 中使用,因此需要在生成页面时知道它,而不是在页面访问服务器或从环境中知道。 (不确定我是否正确传达了最后一点)

I need to know the full url for the current page from within a Mako template file in Pylons.

The url will be using in an iframe contained within the page so it needs to be known when the page is being generated rather than after the page hits the server or from the environment. (Not sure if I am communicating that last bit properly)

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

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

发布评论

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

评论(2

怕倦 2024-09-07 00:33:34

不确定这是否是 Pylons 的做事方式,但 ${request.url} 似乎对我有用。

Not sure if this is the Pylons way of doing things but ${request.url} seems to work for me.

嗼ふ静 2024-09-07 00:33:34

我认为您可以使用 h.url_for('',qualified=True) 来获取完整的 URL。
确保您已在帮助程序文件中导入 url_for:from paths.util import helpers as h

查看 http://pylonshq.com/docs/en/0.9.7/thirdparty/routes/#routes.util.url_for

I think you can use h.url_for('', qualified=True) to get the full URL.
Make sure you have imported url_for in your helper file: from routes.util import helpers as h

Have a look at http://pylonshq.com/docs/en/0.9.7/thirdparty/routes/#routes.util.url_for

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