-5
請用django自定義標籤幫助。請分析它!傳送 - django自定義標籤
理念:
在任何模板(父母或子女),我們安裝一個標記{{無繩「頭」}},有一個名字,比如推杆可能不止一個。
在另一邊,我們有阻止此塊
{{ teleputter "head" "unique-name" }} some html {{ teleputterend }}
內容去與適當的無繩名無繩。
請用django自定義標籤幫助。請分析它!傳送 - django自定義標籤
理念:
在任何模板(父母或子女),我們安裝一個標記{{無繩「頭」}},有一個名字,比如推杆可能不止一個。
在另一邊,我們有阻止此塊
{{ teleputter "head" "unique-name" }} some html {{ teleputterend }}
內容去與適當的無繩名無繩。
這聽起來像是你試圖實現模板繼承: http://docs.djangoproject.com/en/dev/topics/templates/#id1
閱讀最好的解釋完整的文檔。讀者文摘版本如下。
從本質上講,你必須用默認值的內容塊基本模板:
base.html
{% block head %} "Default html goes here" {% endblock %}
接下來,您創建一個擴展的基本模板的另一個模板和構建塊,你想更換:
anotherTemplate.html
{% extends "base.html %}
{% block head %} "This replaces the html in the base head block" {% endblock %}
聽起來你的「telepoint」是基本模板中的一個塊,你的「teleputter」是擴展基本模板的塊
這樣做聽起來像你想要做的?你試圖實現什麼不同?
這並不完全清楚你正在努力完成什麼。請詳細說明。 – awithrow 2009-02-27 14:26:19
我試圖做類似繼承{{擴展}}功能,但{{包含}}模板,並有可能發送一個,但很多塊,一個容器 – 2009-02-27 14:29:28