On Sep 17, 10:42 pm, akonsu <[EMAIL PROTECTED]> wrote:
> hello,
>
> i am looking for an advice from people who know django internals well.
>
> to simplify, i have a template that currently uses a custom tag. the
> tag emits the needed markup. suppose the template includes several
> instances of the tag to generate different pieces of the page.
>
> so in other words i have tags inside my <body></body> element.
>
> suppose the tags emit markup that requires a javascript file to be
> included in to the page. usually a JS file is included from the
> <head></head> element of the page. so these tags need to emit markup
> that has to go in to two different locaions in the page.
>
> furthermore, suppose that different instances of the tag want to use
> the same JS file, so i need to check if a link to the JS file has been
> already generated by another instance of the tag.
>
> i have vague ideas about how to do it, for example, i think i can
> subclass the context used during tag rendering and use it somehow, i
> hope. but maybe not, so i am looking for input from the experts.
>
> thanks in advance!
> konstantin

I would write a tag that adds various elements to the context, along
the lines of:
http://docs.djangoproject.com/en/dev/howto/custom-template-tags/#setting-a-variable-in-the-context
One of those elements should be the complete script tag required by
all the other elements.

Then your template could do something like

{% block extrahead %}
{{ myscriptvariable }}
{% endblock %}
...
{% block content %}
{{ mycontentvariable1 }}
..
{{ mycontentvariable2 }}
{% endblock %}

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

Reply via email to