Baris Soner Usakli 11 years ago
commit 60e2938b58

@ -227,6 +227,10 @@
return new RegExp("<!-- BEGIN " + block + " -->[\\s\\S]*<!-- END " + block + " -->", 'g');
}
function makeConditionalRegex(block) {
return new RegExp("<!-- IF " + block + " -->[\\s\\S]*<!-- ENDIF " + block + " -->", 'g');
}
function getBlock(regex, block, template) {
data = template.match(regex);
if (data == null) return;
@ -240,6 +244,19 @@
return data;
}
function getConditionalBlock(regex, block, template) {
data = template.match(regex);
if (data == null) return;
if (self.blocks && block !== undefined) self.blocks[block] = data[0];
data = data[0]
.replace("<!-- IF " + block + " -->", "")
.replace("<!-- ENDIF " + block + " -->", "");
return data;
}
function setBlock(regex, block, template) {
return template.replace(regex, block);
}
@ -289,6 +306,14 @@
block = parse(data[d], namespace, block);
template = setBlock(regex, block, template);
} else {
var conditional = makeConditionalRegex(d),
block = getConditionalBlock(conditional, namespace, template);
if (block && !data[d]) {
template = template.replace(conditional, '');
}
template = replace(namespace + d, data[d], template);
}
}

Loading…
Cancel
Save