title: Building HTML with templates versus building it in javascript?
body: <p>I recently started making web apps, and while I make some stuff that works, I'm not sure of the best practices.</p>
  
  <p>Up to now, I've mostly used the templating systems of Django, web.py and PHP. But now that I'm using jQuery and nice ajaxy magic to get data from the server without refreshing the client, I'm seeing the advantages of building the HTML directly in javascript (so I can just send a small json object to the client and have him figure out what to change and how).</p>
  
  <p>So now I have some bits that are rendered with templates, and some that are built in javascript, and even one horrid case where there's a mix of both, a web.py template that generates a javascript function that creates a HTML table - feels like C macros all over again! (I'll refactor that away eventually)</p>
  
  <p>Is this a common problem in web development? Any recommended best practices, such as "use json for everything, render as much as possible in javascript", "use library foo", etc.? Any good heuristics for what to handle with templates, and what to handle with javascript?</p>
  
  <p>Searching a bit here, I found someone <a href="https://stackoverflow.com/questions/449780/recommended-javascript-html-template-library-for-jquery">asking about javascript templates</a>, which does seem like a possible solution.</p>