From: Mike Taylor Date: Fri, 25 Apr 2014 16:03:11 +0000 (+0100) Subject: Add team.registerTemplate method. X-Git-Tag: 1.0.0~846 X-Git-Url: http://git.indexdata.com/?p=mkws-moved-to-github.git;a=commitdiff_plain;h=f72d7b0b24b73b8468e55906ea31ca33344ebb4c Add team.registerTemplate method. Allows a template-name to be associated with text. This mapping is stored in the new private variable m_tempateText. Enables individual widgets to carry their own templates. --- diff --git a/src/mkws-team.js b/src/mkws-team.js index a76c65c..cf4794b 100644 --- a/src/mkws-team.js +++ b/src/mkws-team.js @@ -26,7 +26,8 @@ function team($, teamName) { "last": $.now() }; var m_paz; // will be initialised below - var m_template = {}; + var m_tempateText = {}; // widgets can register tempates to be compiled + var m_template = {}; // compiled templates, from any source var m_config = mkws.objectInheritingFrom(mkws.config); var m_widgets = {}; // Maps widget-type to object @@ -616,6 +617,11 @@ function team($, teamName) { that.renderDetails = renderDetails; + that.registerTemplate = function(name, text) { + m_tempateText[name] = text; + }; + + function loadTemplate(name) { var template = m_template[name]; @@ -631,6 +637,9 @@ function team($, teamName) { } if (!source) { + source = m_tempateText[name]; + } + if (!source) { source = defaultTemplate(name); }