From e327eccb93e2bc513fcbb7ab302783d6bce83884 Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Tue, 14 Feb 2012 22:30:51 -0800 Subject: Creating NinjaTemplate to HTML function This function will need to be cleaned up and possibly moved once the MVC structure is in-place for the document. --- js/mediators/io-mediator.js | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'js/mediators') diff --git a/js/mediators/io-mediator.js b/js/mediators/io-mediator.js index 599b7d84..2008e40f 100644 --- a/js/mediators/io-mediator.js +++ b/js/mediators/io-mediator.js @@ -142,12 +142,7 @@ exports.IoMediator = Montage.create(Component, { // switch (file.mode) { case 'html': - file.document.content.document.body.innerHTML = file.body; - file.document.content.document.head.innerHTML = file.head; - if (file.style) { - file.document.content.document.head.getElementsByTagName('style')[0].innerHTML = this.getCssFromRules(file.style.cssRules); - } - contents = file.document.content.document.documentElement.outerHTML; + contents = this.parseNinjaTemplateToHtml(file); break; default: contents = file.content; @@ -189,6 +184,21 @@ exports.IoMediator = Montage.create(Component, { } }, //////////////////////////////////////////////////////////////////// + //TODO: Expand to allow more templates + parseNinjaTemplateToHtml: { + enumerable: false, + value: function (template) { + // + template.document.content.document.body.innerHTML = template.body; + template.document.content.document.head.innerHTML = template.head; + //TODO: Remove temp fix for styles + if (template.style) { + template.document.content.document.head.getElementsByTagName('style')[0].innerHTML = this.getCssFromRules(template.style.cssRules); + } + return template.document.content.document.documentElement.outerHTML; + } + }, + //////////////////////////////////////////////////////////////////// //Method to return a string from CSS rules (to be saved to a file) getCssFromRules: { enumerable: false, -- cgit v1.2.3