Tornado的模版里如何检查不存在的变量?

Django里的模版可以检查一个变量是不是存在。

那么在Tornado里呢?

不过Tornado的维护者Ben Darnell说:

I think arguments passed in to templates show up in globals() instead of locals(), but this is an implementation detail that should not be relied upon. In general I recommend making sure the variable you need always exists, even if it is None or "" by default. If that's not practical, I suggest making it an attribute of some object that always exists, such as the RequestHandler. This way you can say {{getattr(handler, "var", "")}}.