-
-
Notifications
You must be signed in to change notification settings - Fork 112
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Passing template variables to custom tags/filters? #78
Comments
The tag will be passed a string literal, so if you wish to use the value then you would have to do that with a filter, e.g: (add-filter!
:getter
(fn [field] (str (if (= (:javaType field) "boolean") "is" "get") (:name field))))
(render
"{% for field in model.fields %}
{{field|getter}}
{% endfor %}"
{:model {:fields [{:javaType "boolean"} {:javaType "integer"}]}}) |
Thanks! Are there plans on adding the same functionality to custom tags as well (seeing how it already works for built-in tags)? |
I'd have to look what would be involved in exposing that to custom tags, but it probably wouldn't happen in the near future. And since the filters can already be used for this purpose I don't think that's a pressing issue. |
With PR: #304 you can now use |
Hello,
Is this possible?
E.g.
... or using a filter instead of the tag.
And in the template:
The text was updated successfully, but these errors were encountered: