Hello,
I’m building a single page webapplication. The data is sending back and forward with AJAX and JSON. I’m considering to use a templating engine like mustache.js or John Resig micro templating engine, … but what is the advantage of a templating engine? As far as I understand … it only changes variables in other variables and add more complexibility and syntax to your code?
Why not use the following syntax?
[CODE]
// lang = language object
GLOBAL.accountTemplate = function(data, lang) {
return ‘<h1>Welcome, ‘ + data.username + ‘</h1>’;
}
$.ajax(‘/account.php’, {‘username’:username, ‘password’:password}, function(data) {
var template = GLOBAL.accountTemplate(data, lang)
$(‘body’).append(template);
},’json’);
I find this much easier than the indistinct syntax of mustache.js
What am I missing here?
Thanks for any help!!!
Christophe