From 56d2a8d11a73cd04c7f1bc20d1ded52b9c1242f2 Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Wed, 15 Feb 2012 10:54:38 -0800 Subject: Revert "Revert "Creating NinjaTemplate to HTML function"" This reverts commit 2e308be9bec5e06d81b2905b65005a232f0a190d. Signed-off-by: Ananya Sen --- js/document/text-document.js | 9 --------- js/mediators/io-mediator.js | 22 ++++++++++++++++------ 2 files changed, 16 insertions(+), 15 deletions(-) (limited to 'js') diff --git a/js/document/text-document.js b/js/document/text-document.js index f2b7b0d8..6f8efaad 100755 --- a/js/document/text-document.js +++ b/js/document/text-document.js @@ -191,14 +191,5 @@ var TextDocument = exports.TextDocument = Montage.create(Montage, { value: function() { // Have the XHR here? } - }/* -, - - save:{ - value:function(){ - //base function - to be overridden - } } -*/ - }); \ No newline at end of file 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