参照:http://djangoproject.jp/doc/ja/1.0/ref/templates/builtins.html
● autoescape
変数の内容をエスケープする
※on off が指定できる
{% autoescape on %}
※on の場合は、タグで囲われている変数はエスケープされる
{{ 変数 }}
※また、on でも safe フィルタがある変数はエスケープされません。
{% endautoescape %}
● comment
{% comment %} から {% endcomment %} までの内容を全て無視します
● cycle
指定した文字列や変数を循環して返します
例1)
~ for文 4回ループだとする ~
<div class="{% cycle 'hoge' 'foo' 'bar' %}" id="1">ほげ</div>
【結果】
<div class="hoge">ほげ</div>
<div class="foo">ほげ</div>
<div class="bar">ほげ</div>
※スペース区切りで定義した値を循環して1つづつ返却する
<div class="hoge">ほげ</div>
例2)
※一度 as 句で変数名 rowcolors を定義する
<div class="{% cycle 'row1' 'row2' fuga as rowcolors %}">ほげ</div>
※以降は定義した変数で循環が可能
<div class="{% cycle rowcolors %}">ほげ</div>
<div class="{% cycle rowcolors %}">ほげ</div>
【結果】
<div class="row1">ほげ</div>
<div class="row2">ほげ</div>
※fuga は変数で、値は[ふが]
<div class="ふが">ほげ</div>
● debug
現在のコンテキストや import されたモジュールなどを含んだデバッグ情報ひと揃 いを出力します
例)
{% debug %}
● filter
タグのコンテンツを変数フィルタ (variable filter) を使ってフィルタします
フィルタはパイプでつないで連鎖でき、引数をもたせることができます。
例)
{% filter force_escape|lower %}
This text will be HTML-escaped, and will appear in all lowercase.
{% endfilter %}
● firstof
タグに渡された変数のうち、False でない最初の変数の値を出力します。
全ての変 数が False であった場合、何も出力しません
例)
※最後に文字列を入れると、全てが False の時に出力される
{% firstof var1 var2 var3 'ほげ' %}