On Sat, 2008-04-26 at 11:56 -0700, Szaijan wrote:
> I'm trying to create an ifequals tag in a template to check if
> request.path equals the URL for a particular view. Either this is not
> possible, or I just can't find the right syntax. As I haven't been
> able to find an example via Google, does anyone know hoe to do this
> correctly?
>
> {% ifequals request.path url('site.app.view_file.view_fn') %}
> code
> {% end ifequals %}
>
> It's the url code I can't seem to get right. More generally, Is there
> a way to use a tag value inside a template comparison clause, and if
> so, what's the correct syntax? To me, this seems like a very common
> task within a template, especially for use in menus and nav bars.
You can't do this (use function calls with arguments in templates. It's
intentionally designed to prevent programming in templates and your
fragment shows exactly why: you've now tightly coupled your template to
a single view and file structure.
Instead, pass in the URL you're wanting to test as a variable to the
template. Then test against the template variable.
Regards,
Malcolm
--
Save the whales. Collect the whole set.
http://www.pointy-stick.com/blog/
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---