> Hi,
>
> I want to use an expression like this:
>
> <a href="?{{ current_qstring|qstring_set:'page={{ i }}' }}">{{ i }}</a>
>
> The first {{ i }} is in another tag.
The "{{ XXX }}" syntax is for variables, not tags (which are written
"{% tagname ... %}".
As a general rule:
1/ you cannot "nest" templatetags this way, period
2/ you don't need the "{{ variable }}" syntax to pass a variable to a
templatetag, BUT the templatetag has to be correctly written to allow
passing variables.
> is there any way to manage this problem?
if you're using the qstring_set filter from http://djangosnippets.org/snippets/553/,
this won't work that way. You'll have to first build the qstring_set
filter's argument as a string (stored as a template variable), then
pass this string to qstring_set.
Storing some expression as template variable can be done using the {%
with <expression> as <varname> %} tag. <expression> can be in the form
"<variable|filter:litteral_or_other_variable>". So all you need is to
provide a custom filter that turn your variable ("i" in the above
example) into "page=<i>". The following Q&D snippet should get you
started, but I strongly sugget you read the relevant part of the
FineManual and improve the snippet before using this in real life
code:
@register.filter
def mkarg(var, name):
return u"%s=%s" % (name, var)
Another - probably better - option would be to write a proper custom
templatetag to use instead of the above somewhat kludgy solution.
HTH
> Thanks,
--
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.
No comments:
Post a Comment