From: Mike Taylor Date: Fri, 29 Nov 2013 12:42:29 +0000 (+0000) Subject: Provide defaultTemplate() function (for "Record" only, so far). X-Git-Tag: 0.9.1~148^2~11 X-Git-Url: http://sru.miketaylor.org.uk/?a=commitdiff_plain;h=72e0d26475c1cee0ef58f8a0e31b01cd1b58940a;p=mkws-moved-to-github.git Provide defaultTemplate() function (for "Record" only, so far). maybeLoadTemplate() now falls back to defaultTemplate() when no template is provided in the HTML of an application. --- diff --git a/tools/htdocs/mkws.js b/tools/htdocs/mkws.js index 0638ee4..5b428bf 100644 --- a/tools/htdocs/mkws.js +++ b/tools/htdocs/mkws.js @@ -714,10 +714,7 @@ function maybeLoadTemplate(name) { var source = $("#mkwsTemplate" + name).html(); if (!source) { - debug("no template '" + name + "': falling back to default behaviour"); - // Mark template as not provided - mkws['template' + name] = 0; - return; + source = defaultTemplate(name); } var template = Handlebars.compile(source); @@ -726,6 +723,74 @@ function maybeLoadTemplate(name) } +function defaultTemplate(name) +{ + if (name === 'Record') { + return '\ + \ + \ + \ + \ + \ + {{#if md-date}}\ + \ + \ + \ + \ + {{/if}}\ + {{#if md-author}}\ + \ + \ + \ + \ + {{/if}}\ + {{#if md-electronic-url}}\ + \ + \ + \ + \ + {{/if}}\ + {{#if-any location having="md-subject"}}\ + \ + \ + \ + \ + {{/if-any}}\ + \ + \ + \ + \ +
Title\ + {{md-title}}\ + {{#if md-title-remainder}}\ + ({{md-title-remainder}})\ + {{/if}}\ + {{#if md-title-responsibility}}\ + {{md-title-responsibility}}\ + {{/if}}\ +
Date{{md-date}}
Author{{md-author}}
URL\ + {{#each md-electronic-url}}\ + {{this}}
\ + {{/each}}\ +
Subject\ + {{#first location having="md-subject"}}\ + {{#if md-subject}}\ + {{md-subject}}\ + {{/if}}\ + {{/first}}\ +
Locations\ + {{#commaList location}}\ + {{attr "@name"}}{{/commaList}}\ +
\ +'; + } + + var s = "There is no default '" + name +"' template!"; + alert(s); + return s; +} + + function defaultRenderDetails(data, marker) { var details = '';