On Sunday, March 20, 2011 9:57:04 PM UTC, Turner wrote:
>
> 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: 
>
> You don't need to look at the code, this is explicitly documented:
http://docs.djangoproject.com/en/1.2/howto/custom-template-tags/#passing-template-variables-to-the-tag
 

> 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. 
>

Yes, since it is documented. 

 

> 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?


AFAIK that should just work. The `with` tag, for example, works fine with 
arguments that include filters. 
--
DR. 

-- 
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+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to