-
-
Notifications
You must be signed in to change notification settings - Fork 114
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
known-variables and tags #306
Comments
That does look like a bug. I won't have a chance to take a look in the near future, but a PR would be welcome. |
Is that just an alternate syntax for |
No, that user=> (html/render "{% if {{var}} %}yes{% else %}no{% endif %}" {:var true})
"no"
user=> (html/render "{% if var %}yes{% else %}no{% endif %}" {:var true})
"yes" |
Ah yeah that's a good good point, nesting a var inside a condition this way isn't actually supported. I missed that bit. I think we can close this then. |
Sorry, my example was too simple. I meant to refer to the recently added capability to have vars in custom tags: (selmer/add-tag!
:ifendswith
(fn [args context-map content]
(let [args (map #(selmer/resolve-arg % context-map) args)]
(if (str/ends-with? (first args) (second args))
(-> content :ifendswith :content)
(-> content :else :content))))
:else :endifendswith)
(selmer/known-variables "{% ifendswith {{var}} \"foo\" %}{{var}} ends with foo!{% endifendswith %}")
;; #{:{{var}} :var} |
This is still var-in-a-tag which isn't supported by Selmer itself. You're explicitly calling However: user=> (selmer/known-variables "{% ifendswith var1 \"foo\" %}{{var2}} ends with foo!{% endifendswith %}")
#{:var1 :var2} That seems inconsistent -- But I think perhaps Even if you use s.f-p/l-a and user=> (selmer/known-variables "{% ifendswith @var1 \"foo\" %}{{var2}} ends with foo!{% endifendswith %}")
#{:var2 :@var1} |
It does look like using |
Thanks both - my initial need for this was to check whether all variables of a template are provided. But the custom-tag example, as I now understand, is not something you would use often. |
It seems that
#'parser/known-variables
does not handle variables in tags correctly:The text was updated successfully, but these errors were encountered: