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/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