【问题标题】:Python web.py template, how to escape (.) dotPython web.py 模板,如何转义 (.) 点
【发布时间】:2011-10-02 12:44:20
【问题描述】:

在 web.py 模板中:index.html 我写了:

$def with(s)
<img src="$s.filename.png" />

s.filename 的值是“图片”所以我想打印

<img src="picture.png" />

但是我如何告诉 web.py 模板系统不要使用 $s.filename.png 只使用 $s.filename 并在其中添加“.png”?

【问题讨论】:

    标签: python templates escaping web.py


    【解决方案1】:

    Templetor docs

    表达式可以包含在 () 或 {} 中以进行显式分组。

    所以,在你的情况下,

    <img src="${s.filename}.png" />
    

    【讨论】:

      猜你喜欢
      • 2014-10-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-09-27
      • 2012-03-02
      • 2023-04-02
      • 1970-01-01
      相关资源
      最近更新 更多