Parse template variables in custom tag
I'm working on a custom tag to which I would like to be able to pass
template variables and filters. I found
<code>Variable(value).resolve(context)</code> in the Django source. I
have a couple of questions:
1) Is it safe to use <code>Variable()</code>? That is, is it part of
the public API? Not having visibility modifiers makes it a bit
difficult to tell.
2) Variable.resolve() works fine for, well, resolving a variable, but
doesn't work with filters. That is, if I pass to my tag
<code>some.context.variable|some_filter</code>, the tag will throw up
on the last bit, saying that it can't find an attribute/key/method
called "variable|some_filter". Is there an easy way I can have my tag
apply any filters to the value passed in?
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home