Commit 964d059e authored by Penny Leach's avatar Penny Leach
Browse files

added unique id validation in template parser. fixed the blog and profile

template to obey this
parent 3aaaa1b9
......@@ -39,7 +39,7 @@ function template_parse($templatename) {
preg_match_all('/(.*?)\{\{(.*?)\}\}/xms', $fragment, $matches, PREG_SET_ORDER);
$strlen = 0;
$blockids = array();
foreach ($matches as $m) {
$temp = array('type' => 'html',
'content' => $m[1],
......@@ -49,11 +49,17 @@ function template_parse($templatename) {
'data' => template_parse_block($m[2]),
);
$t[] = $temp;
$blockids[] = $temp['data']['id'];
$strlen += strlen($m[0]);
}
if (count($blockids) != count(array_unique($blockids))) {
$dups = array_unique(array_diff_assoc($blockids, array_unique($blockids)));
throw new InvalidArgumentException("This template ($templatename) has duplicate block ids: " . implode(', ', $dups));
}
$temp = array('type' => 'html',
'content' => substr($fragment, $strlen),
);
......
......@@ -9,7 +9,7 @@
<td>
{{block type="label" id="tpl_blogslabel"}}<br>
{{block type="artefact" id="tpl_blog1" artefacttype="blog"}}<br>
{{block type="artefact" id="tpl_blog1" artefacttype="blog"}}<br>
{{block type="artefact" id="tpl_blog2" artefacttype="blog"}}<br>
</td>
<td>
{{block type="label" id="tpl_profilelabel"}}<br>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment