我無法在DTL中找到'as'保留字的解釋。'as'保留字在Django模板語言中是如何工作的?
get_cart裏面carton_tags:
{% load carton_tags %} {% get_cart as cart %}
我已經審查了Django的模板語言的文件,並已閱讀DTL代碼沒有成功保留/關鍵字/「標籤」。
我的問題的一部分可能是試圖在這些文檔中找到字符串'as','as','as'或'as'。
文檔:https://docs.djangoproject.com/en/1.9/topics/templates/#templates
來源:https://github.com/django/django/blob/master/django/template/defaulttags.py
代碼是從這裏:https://github.com/lazybird/django-carton
謝謝。是否有一個原因分配標籤似乎不保存模板塊之間? – robbintt
這是設計。請參閱[文檔](https://docs.djangoproject.com/en/1.9/howto/custom-template-tags/#setting-a-variable-in-the-context)中的'上下文中的變量範圍' )。 – Alasdair