net*_*yal 1 python templates escaping web.py
在web.py模板中:index.html我写道:
$def with(s)
<img src="$s.filename.png" />
Run Code Online (Sandbox Code Playgroud)
s.filename的值是"picuture"所以我想要打印
<img src="picture.png" />
Run Code Online (Sandbox Code Playgroud)
但是我怎么能告诉web.py模板系统不要使用$ s.filename.png只使用$ s.filename并添加".png"呢?
请参阅Templetor文档:
表达式可以包含在()或{}中以进行显式分组.
所以,在你的情况下,
<img src="${s.filename}.png" />
Run Code Online (Sandbox Code Playgroud)