Python web.py模板,如何转义(。)点

时间:2011-10-02 12:44:20

标签: python templates escaping web.py

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

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

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

<img src="picture.png" />

但我怎么能告诉web.py模板系统不要使用$ s.filename.png只需使用$ s.filename并添加“.png”呢?

1 个答案:

答案 0 :(得分:5)

请参阅Templetor docs

  

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

所以,在你的情况下,

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