title: How to manage Javascript modules in django templates?
body: <p>Lets say we want a library of javascript-based pieces of functionality (I'm thinking jquery):
  For example:</p>
  
  <ol>
  <li>an ajax dialog</li>
  <li>a date picker</li>
  <li>a form validator</li>
  <li>a sliding menu bar</li>
  <li>an accordian thingy</li>
  </ol>
  
  <p>There are four pieces of code for each: some Python, CSS, JS, &amp; HTML.</p>
  
  <p>What is the best way to arrange all these pieces so that:</p>
  
  <ul>
  <li>each javascript 'module' can be neatly reused by different views </li>
  <li>the four bits of code that make up the completed function stay together</li>
  <li>the css/js/html parts appear in their correct places in the response</li>
  <li>common dependencies between modules are not repeated (eg: a javascript file in common)</li>
  </ul>
  
  <p>x--------------</p>
  
  <p>It would be nice if, or is there some way to ensure that, when called from a templatetag, the templates respected the {% block %} directives. Thus one could create a single template with a block each for CSS, HTML, and JS, in a single file.  Invoke that via a templatetag which is called from the template of whichever view wants it.  That make any sense. Can that be done some way already?  My templatetag templates seem to ignore the {% block %} directives.</p>
  
  <p>x--------------</p>
  
  <p>There's some very relevant gasbagging about putting such media in forms here <a href="http://docs.djangoproject.com/en/dev/topics/forms/media/" rel="noreferrer">http://docs.djangoproject.com/en/dev/topics/forms/media/</a> which probably apply to the form validator and date picker examples.</p>