【问题标题】:Using Webhelpers in mako template in Pyramid在 Pyramid 的 mako 模板中使用 Webhelpers
【发布时间】:2011-09-20 06:49:20
【问题描述】:

如何在我的 Pyramid 应用程序的 Mako 模板中使用 Webhelper?


在 Pylons 中,我在模板中使用了全局辅助变量 h,所以我可以简单地做:

${h.stylesheet_link("/css/default.css")}

假设我从 Pylons 中的 webhelpers.html.tags 导入 stylesheet_link lib/helpers.py

我不想使用Akhet 并复制完整的 Pylons 行为,但我只是想获得一些基本(推荐?)使用(引用)官方认可但不是 Pyramid 的包附加组件。

【问题讨论】:

    标签: python pyramid mako akhet


    【解决方案1】:

    文档中的食谱在这里引用了这个

    http://docs.pylonsproject.org/projects/pyramid_cookbook/en/latest/templates/templates.html

    您基本上使用渲染前事件注入帮助程序,以便它在您的模板中可用。希望对您有所帮助。

    【讨论】:

    • 正是我想要的,谢谢。我对 Pyramid 文档的问题通常是我根本无法弄清楚要搜索的 what 和 where...
    猜你喜欢
    • 2013-03-28
    • 2013-03-08
    • 2012-03-02
    • 2012-10-25
    • 2014-09-29
    • 2011-10-14
    • 1970-01-01
    • 2012-08-21
    • 2011-04-16
    相关资源
    最近更新 更多