开发者

What is the method of doing nl2br in Genshi?

hiyas. I using Genshi+Pylons.

please teach me, how use \n to <br/>tag in Genshi?

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}&l开发者_如何学Ct;/p>

Im tried. case 1:

(python code)
c.message = """
foo
bar
"""

NG. display result is "foo bar"

case 2:

(python code)
c.message = """
foo<br />
bar

"""

NG. display result is "foo<br />bar".

displayed escaped stirings!

It was a same deal as <br/> as for <br />.

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.


Try this:

<py:for each="line in message.split('\n')">${line}<br /></py:for>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜