如何将多个变量传递到Webpy中的模板中?

时间:2021-08-10 15:09:34

I would like to pass three different variables into an html template I have using Web.py.

我想将三个不同的变量传递给我使用Web.py的html模板。

Here's what I have:

这就是我所拥有的:

class mainScreen:
    def __init__(self):
        self.render=web.template.render('templates/')
    def GET(self):
        return self.render.firstScreen(variable1, variable2, variable3)
    def POST(self):
        pass

And in my html template:

在我的html模板中:

$def with (variable1)
$def with (variable2)
$def with (variable3)
<!DOCTYPE html>
<html>
<head>
    <title>variable1</title>
</head>
    <body>
        $variable2
        <h1>$variable3</h1>
    </body>
</html>

However, in my html template I'm getting a syntax error at the top where I'm defining with each of the three variables. How can I properly pass in the three variables?

但是,在我的html模板中,我在顶部得到了一个语法错误,我用三个变量中的每个变量定义。我怎样才能正确传递三个变量?

1 个解决方案

#1


0  

Using like

使用像

$def with(product, release, p0,p1,p2,p3, viewby, fromTime, toTime, errormsg, imgurl)

#1


0  

Using like

使用像

$def with(product, release, p0,p1,p2,p3, viewby, fromTime, toTime, errormsg, imgurl)