Re: my first (public) app: django-requires_js_css
I'm also interested in something like this. I've tried it a couple of
different ways, but have not been all the happy with the results/
implementation. It seemed like post-parsing for tokens was trouble
since it hurt performance somewhat, and gets ugly if you are serving
the occasional big file or using a generator for output. I also tried
tracking via a threadlocals global and letting my 'content' render
once to get it updated and then feeding that into another render with
the barebones html/head/body sections. That last one has been working
for a couple of years, but the shame keeps me up at night sometimes.
What I would really love is a way to extend the template parser to
allow for a rendering order per-block, so that some portions of the
template (ie head includes in this case) can be deferred until the
last pass and examine the context for various media 'requests' made by
tags (or other related logic). I had also thought that preprocessing
the nodelists into order queues could allow for a kind of automatic
generator to be made so that multiple nodelists of the same order
could be yielded to the response to stream the output (though doing
that would prevent the automatic css/js stuff). I don't know if any
of this is even reasonably possible with the current template system,
but I'd sure love if it was.
An easy but ugly approach might be a template tag that 'wraps' the
entire template:
<html>
{% delayedrender %}
<head>
{% defer %}This stuff gets rendered last{% enddefer %}
</head>
<body>
This stuff gets rendered first
</body>
{ % enddelayedrender %}
</html>
Unfortunately I haven't had enough time to explore either option any
further.
--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home