rather than using a custom string templating find/replace - how about using [underscore template](http://underscorejs.org/#template)?