* content with the their respective translated dates.
*
* @param {String} content The content in which string placeholders are to be found.
- * @param {Array} strings The strings to replace with.
+ * @param {Array} dates The dates to replace with.
* @return {String} The treated content.
*/
Renderer.prototype.treatDatesInContent = function(content, dates) {
return renderer.render(templateName, context, themeName);
},
+ /**
+ * Every call to render creates a new instance of the class and calls render on it. This
+ * means each render call has it's own class variables.
+ *
+ * This alernate to the standard .render() function returns the html and js in a single object suitable for a
+ * native Promise.
+ *
+ * @method renderForPromise
+ * @private
+ * @param {string} templateName - should consist of the component and the name of the template like this:
+ * core/menu (lib/templates/menu.mustache) or
+ * tool_bananas/yellow (admin/tool/bananas/templates/yellow.mustache)
+ * @param {Object} context - Could be array, string or simple value for the context of the template.
+ * @param {string} themeName - Name of the current theme.
+ * @return {Promise} JQuery promise object resolved when the template has been rendered.
+ */
+ renderForPromise: function(templateName, context, themeName) {
+ var renderer = new Renderer();
+ return renderer.render(templateName, context, themeName)
+ .then(function(html, js) {
+ return {
+ html: html,
+ js: js,
+ };
+ });
+ },
+
/**
* Every call to renderIcon creates a new instance of the class and calls renderIcon on it. This
* means each render call has it's own class variables.
*/
appendNodeContents: function(element, html, js) {
domAppend(element, html, js);
- }
+ },
};
});