yogthos/Selmer

Passing template variables to custom tags/filters?

Open

#78 aperta il 8 apr 2015

Vedi su GitHub
 (4 commenti) (0 reazioni) (0 assegnatari)Clojure (86 fork)batch import
enhancementhelp wanted

Metriche repository

Star
 (670 star)
Metriche merge PR
 (Merge medio 39m) (4 PR mergiate in 30 g)

Descrizione

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

Guida contributor