webpy中的多行html变量

时间:2012-02-01 20:53:21

标签: python templates multiline web.py

我在这个模板中有一个片段:

$ html = """<p id="address">
    Адрес:
    <span id="postcode">123456</span>,
    <span id="city">Москва</span>,
    <span id="street">Красная площадь</span>,
    <span id="houseNumber">д.1</span>,
    <span id="addhouseNumber">стр.1</span>,
    <span id="officeNumber">офис 12</span>
</p>"""
$:htmlLoop(entry, 'address', html)

当我尝试渲染它时,我得到追溯:

extend_([u'</p>"""\n'])








                           ^
SyntaxError: unexpected character after line continuation character

并不依赖于我是否使用\"""来划分行。

1 个答案:

答案 0 :(得分:1)

web.py不支持三引号字符串。你可以像这样完成你想要做的事情:

$def html():
    <p id="address">
        Адрес:
        <span id="postcode">123456</span>,
        <span id="city">Москва</span>,
        <span id="street">Красная площадь</span>,
        <span id="houseNumber">д.1</span>,
        <span id="addhouseNumber">стр.1</span>,
        <span id="officeNumber">офис 12</span>
    </p>
$:htmlLoop(entry, 'address', html())