From 88d2ed49777fe955226df0b4cbe509aa042e07e6 Mon Sep 17 00:00:00 2001 From: Mike Taylor Date: Tue, 10 Jun 2014 16:47:29 +0100 Subject: [PATCH] Rename the two "template" variables to t1 and t2. t2 is now precomputed, rather than once each time through the loop. Crucially, t2 now tries to load a field-specific facet template before backing down to the generic one. --- src/mkws-widget-termlists.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/mkws-widget-termlists.js b/src/mkws-widget-termlists.js index 3df2f60..fef616f 100644 --- a/src/mkws-widget-termlists.js +++ b/src/mkws-widget-termlists.js @@ -39,10 +39,18 @@ mkws.registerWidgetType('Facet', function() { return '[Widget ' + that.team.name() + ':' + that.type + '(' + name + ')]'; }; + var t2 = that.team.loadTemplate('Facet-' + caption); + that.log("template for Facet-" + caption + " is " + !!t2); + if (!t2) { + that.log("no " + caption + "-specific template, falling back"); + t2 = that.team.loadTemplate('Facet'); + } + that.log("template for Facet is " + !!t2); + that.team.queue("termlists").subscribe(function(data) { data = data[name]; - var template = that.team.loadTemplate('facetTitle-' + caption, mkws.M(caption)) - var title = template({ query: that.config.query }); + var t1 = that.team.loadTemplate('facetTitle-' + caption, mkws.M(caption)) + var title = t1({ query: that.config.query }); var acc = []; acc.push('
', title, '
'); @@ -56,8 +64,7 @@ mkws.registerWidgetType('Facet', function() { fn = 'limitTarget'; field = data[i].id; } - var template = that.team.loadTemplate('Facet'); - var s = template({ + var s = t2({ team: teamName, fn: fn, field: field, -- 1.7.10.4