From 0910ada5fb3716c25844b10e94fcb86c04f6a981 Mon Sep 17 00:00:00 2001 From: Jeremy Ruston Date: Sat, 7 Jan 2012 20:08:11 +0000 Subject: [PATCH] Added support for compiling and rendering raw text blocks --- js/WikiStore.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/js/WikiStore.js b/js/WikiStore.js index 8bc926f64..6552c697c 100755 --- a/js/WikiStore.js +++ b/js/WikiStore.js @@ -201,6 +201,15 @@ WikiStore.prototype.parseTiddler = function(title) { } }; +/* +Compiles a block of text of a specified type into a JavaScript function that renders the text in a particular MIME type +*/ +WikiStore.prototype.compileText = function(type,text,targetType) { + /*jslint evil: true */ + var tree = this.parseText(type,text); + return eval(tree.compile(targetType)); +}; + /* Compiles a JavaScript function that renders a tiddler in a particular MIME type */ @@ -218,6 +227,15 @@ WikiStore.prototype.compileTiddler = function(title,type) { } }; +/* +Render a block of text of a specified type into a particular MIME type +*/ +WikiStore.prototype.renderText = function(type,text,targetType,asTitle) { + var tiddler = this.getTiddler(asTitle), + fn = this.compileText(type,text,targetType); + return fn(tiddler,this,utils); +}; + /* Render a tiddler to a particular MIME type. Optionally render it with a different tiddler as the context. This option is used to render a tiddler through a template eg