I'm new to Django, and I'm struggling with something that seems to be
do-able.  Maybe I'm thinking about the problem wrong.  Help?

I'm converting an application from hand-constructed Python that builds
a large web site to Django templates.  The site has multiple layers.
All pages share the same basic layout, header, footer, etc.  On each
intermediate layer, some features are added, but there are several
flavors of page within each layer.  I thought I could arrange it as
follows:

base.html
-------------------------
<html>
<head><title>{{title}}</title></head>
<body>
Header Stuff<p>
{%block contents%}{%endblock%}
Footer Stuff<p>
</body></html>
-------------------------

layer1.html
-------------------------
{%extends base.html%}
{%block contents%}
Layer One has cool {{noun}}.<p>
{%block layer_special%}More layer specialization here, that will be
filled in later.{%endblock%}
Layer One closing stuff.<p>
{%endblock%}
-------------------------

layer1-special1.html
-------------------------
{%extents layer1.html%}
{%block layer_specials%}
You need more than {{noun}}.  You can be special.  Sometime you gotta
{{verb}}.<p>
{%endblock%}
-------------------------

In Python:
from django.template import Context, Template, loader
t = loader.get_template("layer1-special1.html")
c = Context( { "title":"Layer One Special One", "noun":"Stuff",
"verb":"Django" } )
print t.render(c)

should print:

<html>
<head><title>Layer One Special One</title></head>
<body>
Header Stuff<p>

Layer One has cool Stuff.<p>

You need more than Stuff.  You can be special.  Sometime you gotta
Django.<p>

Layer One closing stuff.<p>

Footer Stuff<p>
</body></html>

But Django gets an error when it tries to parse the template.  The
error is "django.template.TemplateSyntaxError: Invalid block tag:
'endblock' ".

This is a simple sample, there are at least three different "layers",
and each layer has between 3 and 5 different "specializations".  At
each level there is significant added html and django code, and I'm a
big believer in only doing something once and not duplicating code.

Help?


--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to