title: Django templatetag "order of processing"
body: <p>I am trying to write a set of template tags that allow you to easily specify js and css files from within the template files themselves.  Something along the lines of <code>{% requires global.css %}</code>, and later in the request, <code>{% get_required_css %}</code>.</p>
  
  <p>I have this mostly working, but there are a couple of issues.  We'll start with the 'timing' issues.  </p>
  
  <p>Each template tag is made up of two steps, call/init and render.  Every call/init happens before any render procedure is called.  In order to guarantee that all of the files are queued before the <code>{% get_required_css %}</code> is rendered, I need to build my list of required files in the call/init procedures themselves.</p>
  
  <p>So, I need to collect all of the files into one bundle <b>per request</b>.  The <code>context</code> dict is obviously the place for this, but unfortunately, the call/init doesn't have access to the context variable.  </p>
  
  <p>Is this making sense?  Anyone see a way around this (without resorting to a hack-y global <code>request</code> object)?  </p>
  
  <p>Another possibility to store these in a local dict but they would still need to be tied to the request somehow... possibly some sort of <code>{% start_requires %}</code> tag?  But I have no clue how to make that work either.</p>