Add swig templating engine support

http://paularmstrong.github.com/swig/

Swig layouts are a little different and required a little custom code outside the adapter - in base_controller.js

This also includes the "fix-template-race" branch