yogthos/Selmer

Passing template variables to custom tags/filters?

開放

#78 建立於 2015年4月8日

 (4 則留言) (0 個反應) (0 位負責人)Clojure (121 個分叉)batch import
enhancementhelp wanted

倉庫指標

星標
 (1,042 顆星)
PR 合併指標
 (30 天內沒有已合併 PR)

描述

Hello, Is this possible?

E.g.

(selmer/add-tag! :getter
                 (fn [args context-map]
                   (let [field (first args)]
                     (str (if (= (:javaType field) "boolean") "is" "get") (:name field)))))

... or using a filter instead of the tag. And in the template:

{% for field in model.fields %}
    {% getter field %}
{% endfor %}

貢獻者指南