Added support for compiling and rendering raw text blocks

This commit is contained in:
Jeremy Ruston 2012-01-07 20:08:11 +00:00
parent 4c19c76461
commit 0910ada5fb
1 changed files with 18 additions and 0 deletions

View File

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