You do not have to do this. You can (for example) save your templates in a .js file (sort of like a message directory):
// this is a file full of templates
var SITE_TEMPLATES = {
ERROR_1: 'This is an error template: the error is ${error.msg}',
WHATEVER: 'I cannot make this stuff up but you get the ${idea}'
};
Pull this and then you can use patterns through
$('#someplace').append($.tmpl(SITE_TEMPLATES.ERROR_1, { error: { msg: "hello world" }}));
, $.tmpl() , .
, Javascript , <script> HTML . AJAX <div> - . , , .
, .