I was hoping someone could explain to me what the exact behavior would
be if the Extends Node in the template was not first.

Here's my use-case scenario: I need to maintain separate mobile and
desktop templates for my site. I'm finding out that 90% of my
templates would be identical -- the only difference would be which
templates they extended from -- e.g. {% extends 'base.html' %} vs. {%
extends 'm_base.html' %}.

My views insert a mobile variable into the context if they think the
user-agent is a mobile device. So I want behavior like this:

{% if mobile_var %}
  {% extends 'm_base.html' %}
{% else %}
  {% extends 'base.html' %}
{% endif %}

This won't work because the the extends tag doesn't really understand
the {% if %} tag above it and just throws up when it comes to the {%
else %} tag. So as an alternative, I plan to encapsulate that logic in
a custom extends tag -- e.g. {% mextends mobile_var 'm_base.html'
'base.html' %} that wraps the existing do_extends function.

When going over the ExtendNode source code however, I noticed it has
to be first. However, in order to use my custom tag, I need to call {%
load %}, and that call means any ExtendNode created after that can't
be first. I'm tempted to simply disable that, but I'm not really sure
what will happen if I do. Are there any problems with calling a load
tag before an extends?

Thanks!

-- Andrew


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