From fdbdcdef26151c781613bf4da19c152189b8f28d Mon Sep 17 00:00:00 2001 From: miker Date: Wed, 23 Jun 2010 18:03:42 +0000 Subject: [PATCH] protect templated slots from errors when there are no template variables git-svn-id: svn://svn.open-ils.org/ILS/trunk@16790 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/web/js/dojo/openils/BibTemplate.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Open-ILS/web/js/dojo/openils/BibTemplate.js b/Open-ILS/web/js/dojo/openils/BibTemplate.js index 1b0f8334d..fdc357795 100644 --- a/Open-ILS/web/js/dojo/openils/BibTemplate.js +++ b/Open-ILS/web/js/dojo/openils/BibTemplate.js @@ -133,6 +133,7 @@ if(!dojo._hasResource["openils.BibTemplate"]) { if (templated) { if (debug) alert('BibTemplate debug -- slot template innerHTML:\n' + slot.innerHTML); var template_values = {}; + var template_value_count = 0; dojo.query( '*[type=opac/template-value]', @@ -140,11 +141,14 @@ if(!dojo._hasResource["openils.BibTemplate"]) { ).orphan().forEach(function(x) { var name = x.getAttribute('name'); var value = (new Function( 'item_list', 'BT', 'slotXML', 'slot', unescape(x.innerHTML) ))(item_list,BT,bib,slot); - if (name && (value || value == '')) template_values[name] = value; + if (name && (value || value == '')) { + template_values[name] = value; + template_value_count++; + } }); if (debug) alert('BibTemplate debug -- template values:\n' + dojo.toJson( template_values )); - slot.innerHTML = dojo.string.substitute( unescape(slot.innerHTML), template_values ); + if (template_value_count > 0) slot.innerHTML = dojo.string.substitute( unescape(slot.innerHTML), template_values ); } var handler_node = dojo.query( '*[type=opac/slot-format]', slot )[0]; -- 2.11.0