在Genshi中执行nl2br的方法是什么? [英] What is the method of doing nl2br in Genshi?
问题描述
hiyas.我正在使用Genshi + Pylons.
hiyas. I using Genshi+Pylons.
请教我,如何使用\ n标记Genshi中的< br/>?
please teach me, how use \n to <br/>tag in Genshi?
我希望在php中获得与" nl2br "相同的结果以更改行.
还是不存在解决方案?
I hope to obtain the same result as "nl2br" in php to change line.
Or, does not the solution exist?
我正在为一些文本分配模板.
i'm assign template to some text.
(genshi template)
<p>${c.message}</p>
我尝试过. 情况1:
(python code)
c.message = """
foo
bar
"""
NG.显示结果为"foo bar"
NG. display result is "foo bar"
情况2:
(python code)
c.message = """
foo<br />
bar
"""
NG.显示结果为"foo&br;&bar".
显示逃脱的搅动!
这与< br/>至于< br/>.
NG. display result is "foo<br />bar".
displayed escaped stirings!
It was a same deal as <br/> as for <br />.
后记.
我想避免使用pre标签.
Postscript.
I want to avoid using the pre tag.
谢谢.
当因为不好而难以阅读时,对不起英语.
thanks.
When it is not easy to read because it is not good, I'm sorry by English.
推荐答案
尝试一下:
<py:for each="line in message.split('\n')">${line}<br /></py:for>
这篇关于在Genshi中执行nl2br的方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!