Committer: dpetrov
LJSUP-11969: Add an api to insert translated template into pageU trunk/htdocs/js/basic.js
Modified: trunk/htdocs/js/basic.js =================================================================== --- trunk/htdocs/js/basic.js 2012-04-27 12:40:49 UTC (rev 21831) +++ trunk/htdocs/js/basic.js 2012-04-27 12:42:35 UTC (rev 21832) @@ -327,13 +327,22 @@ cssNode.href = fileName; head.appendChild(cssNode); - - //console.log(fileName + ' injected from ' + w.location.href); }; LJ.UI = LJ.UI || {}; + +/** + * Private namespace to hold information about templates. + */ LJ.UI._templates = {}; +/** + * Register new template in system. + * + * @param {string} name The name of the template. + * @param {string} id Id of the script tag containing the templates or the template text. + * @param {string=JQuery} type Type of the template. Default is jquery templates. + */ LJ.UI.registerTemplate = function(name, id, type) { var node = jQuery('#' + id), template; @@ -360,6 +369,15 @@ }; +/** + * Render the template with the data. Current version returns jQuery object + * but surely should be able to return rendered strings. + * + * @param {string} name The name of the template. Template should be registered. + * @param {Object} data Data object to inset into template + * + * @return {jQuery} jQuery object containing new markup. + */ LJ.UI.template = function(name, data) { var tmplObj = LJ.UI._templates[name], html;