Separating presentation and data in applications an accepted design practice, but somehow it is not as common in-browser apps as it is on the server side.
Here's an architecture of a dynamic web app that works well for me:
- an app server exposes JSON and no HTML. (eg django or rails)
- html/css/js is completely static (eg. on S3/CDN) and defines UI as a set of HTML templates.
- once html/js is loaded in the browser, the browser makes an AJAX call to the server to get the JSON data
- in-browser JS expands a template, the data is rendered out
In this architecture, http://code.google.com/p/google-jstemplate/ is key. Check it out.