我有一个模板,它显示了许多从服务器传递的值,我的问题是如何将这些值传递给模板文件。我的处理程序代码如下: class AdminHandler(tornado.web.RequestHandler): def get(self, *args, **kwargs): #respond to a get method #self.write("AdminHandler:: Inside GET function")
userName = "Alwin Doss"
welcomeMessage = "Good evening are you enjoying kids dance"
items = {}
items["userName"] = userName
items["welcomeMessage"] = welcomeMessage
self.render("web/admin.html", title="Admin Page", items=items)
我的模板代码如下: {% items['userName'] %} {% items['welcomeMessage'] %} {% end %}
问题是我无法在模板文件中访问这些值。我收到以下错误:
raise ParseError("unknown operator: %r" % operator) ParseError: unknown operator: "items['userName']" ERROR:root:500 GET /admin (127.0.0.1) 3.27ms