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 %}

贡献者指南