Don't try to use Titlecase wrapper if not defined
authorJeff Godin <jgodin@tadl.org>
Thu, 26 Dec 2013 19:54:29 +0000 (14:54 -0500)
committerJeff Godin <jgodin@tadl.org>
Thu, 26 Dec 2013 19:54:29 +0000 (14:54 -0500)
Don't try to call the function passed from Lingua::EN::Titlecase
function if the tc variable is undefined.

This avoids having blank titles when the template is used in an
environment where EGWeb isn't passing the function to the templates.

Signed-off-by: Jeff Godin <jgodin@tadl.org>
templates_tadlskin/opac/parts/misc_util.tt2

index a252df3..d340a33 100644 (file)
         titresults = xml.findnodes('//*[@tag="245"]/*[@code="a" or @code="b" or @code="n" or @code="p"]');
         titresults_content = [];
             FOR sub IN titresults;
-                IF sub.getAttribute('code') == 'a';
+                IF sub.getAttribute('code') == 'a' && tc.defined;
                     titresults_content.push(tc.title(sub.textContent.replace(' :$',':')));
-               ELSIF sub.getAttribute('code') == 'b';
+                ELSIF sub.getAttribute('code') == 'b' && tc.defined;
                     titresults_content.push(tc.title(sub.textContent));
                 ELSE;
                     titresults_content.push(sub.textContent);
-               END;
+                END;
             END;
         args.title = titresults_content.join(" ");
         # Avoid ugly trailing syntax on brief titles
@@ -59,9 +59,9 @@
         titsubs = xml.findnodes('//*[@tag="245"]/*[@code]');
         titsubs_content = [];
             FOR sub IN titsubs;
-                IF sub.getAttribute('code') == 'a';
+                IF sub.getAttribute('code') == 'a' && tc.defined;
                     titsubs_content.push(tc.title(sub.textContent.replace(' :$',':')));
-                ELSIF sub.getAttribute('code') == 'b';
+                ELSIF sub.getAttribute('code') == 'b' && tc.defined;
                     titsubs_content.push(tc.title(sub.textContent));
                 ELSE;
                     titsubs_content.push(sub.textContent);