1
0
mirror of https://github.com/owncloudarchive/contacts.git synced 2024-11-29 11:24:11 +01:00

Tweak the micro templating.

This commit is contained in:
Thomas Tanghus 2012-10-25 23:18:36 +02:00
parent eb87100b9f
commit 2cac6c08ca

View File

@ -1280,7 +1280,9 @@ OC.Contacts = OC.Contacts || {
},
// From stackoverflow.com/questions/1408289/best-way-to-do-variable-interpolation-in-javascript
_build: function(o){
return this.$elem.html().replace(/{([^{}]*)}/g,
var data = this.$elem.attr('type') === 'text/template'
? this.$elem.html() : this.$elem.get(0).outerHTML;
return data.replace(/{([^{}]*)}/g,
function (a, b) {
var r = o[b];
return typeof r === 'string' || typeof r === 'number' ? r : a;