Thanks Tom

I went for option 2.  Here's what I've done so far, works ok at the
moment, will need some tidying up and caching.

geturl.py in my mytags/templatetags folder

from django import template
from django.template import Library, Node

register = Library()

class GetUrlNode(Node):
        def __init__(self, url, varname):
                self.url, self.varname = url, varname

        def render(self, context):
                from urllib2 import urlopen
                html_as_string = urlopen(self.url).read()
                context[self.varname] = html_as_string
                return ''

def get_get_url(parser, token):
        bits = token.contents.split()
        if len(bits) != 4:
                raise TemplateSyntaxError, "get_get_url tag takes exactly three
arguments"
        if bits[2] != 'as':
                raise TemplateSyntaxError, "third argument to get_get_url tag 
must
be 'as'"
        return GetUrlNode(bits[1], bits[3])

get_get_url = register.tag(get_get_url)

mega-menu.html templates/shared that gets called into the base.html
with an include

{% load geturl %}
{% get_get_url URL_of_HTML as rendered_html %}
{% autoescape off %}{{ rendered_html }}{% endautoescape %}

Getting there, slowly :-)

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