相关疑难解决方法(0)

jinja2:如何让它失败像djangotemplate一样无声

好吧,我没有找到答案,我确信这很简单,但我只是没有找到如何让它像Django一样工作,因为它找不到变量

我试图使用Undefined并创建我自己的undefined但它给我带来属性错误等问题.

def silently(*args, **kwargs):
    return u''

class UndefinedSilently(Undefined):
    __unicode__ = silently
    __str__ = silently
    __call__ = silently
    __getattr__ = silently
Run Code Online (Sandbox Code Playgroud)

但是当我在这里尝试它失败时TypeError: 'unicode' object is not callable:

{%for dir_name, links in menu_links.items()%}
Run Code Online (Sandbox Code Playgroud)

python django-templates jinja2

5
推荐指数
1
解决办法
1517
查看次数

标签 统计

django-templates ×1

jinja2 ×1

python ×1