运行后,我的浏览器显示以下信息:**
> {% set enabled_scopes_class = 'scopes-' +
> '%s'|format(settings.ALL_SCOPE_ENABLED) + '-' +
> '%s'|format(settings.UNANSWERED_SCOPE_ENABLED) + '-' +
> '%s'|format((request.user.is_authenticated() and
> settings.FOLLOWED_SCOPE_ENABLED)) %} {# Some or all contents of this
> div may be dropped over the search bar via negative margins, to make
> sure that the search bar can occupy 100% of the content width. Search
> bar may have padding on the left and right to accomodate the buttons.
> `#}{# three buttons below are in the opposite order because they are
> floated at the right #}`
请指导我实现目标的正确方法。
呈现模板时看到原始代码的原因是,语句必须在同一行上,包括标记和注释。
对于多行注释,可以使用comment
标签:
{% comment %}
Some or all contents of this
div may be dropped over the search bar via negative margins, to make
sure that the search bar can occupy 100% of the content width. Search
bar may have padding on the left and right to accomodate the buttons.
three buttons below are in the opposite order because they are
floated at the right
{% endcomment %}
至于您的set
陈述:我不知道任何set
陈述(它是第三方标记吗?),但是模板语言在设计上并不像Python代码那么强大。不允许将括号用于对语句进行分组,并且您不能像在python中一样使用带参数的函数来调用函数。您也不能使用+
和format
不是定义的模板过滤器来连接值。我建议您阅读文档中的模板。
像您在此处尝试执行的操作一样,应在视图函数中完成更高级的逻辑,并将其传递给模板的上下文。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句