1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2025-11-29 21:45:16 +00:00

Major refactoring of rendering mechanism

We now use a fake DOM implementation on the server to let us share more
rendering code between the text output vs. DOM output paths.
This commit is contained in:
Jeremy Ruston
2013-05-17 10:12:25 +01:00
parent bf4fede34e
commit 551ebdc005
18 changed files with 167 additions and 107 deletions

View File

@@ -20,6 +20,7 @@ Options include:
wiki: mandatory reference to wiki associated with this render tree
context: optional hashmap of context variables (see below)
parentRenderer: optional reference to a parent renderer node for the context chain
document: optional document object to use instead of global document
Context variables include:
tiddlerTitle: title of the tiddler providing the context
templateTitle: title of the tiddler providing the current template
@@ -30,6 +31,7 @@ var WikiRenderTree = function(parser,options) {
this.wiki = options.wiki;
this.context = options.context || {};
this.parentRenderer = options.parentRenderer;
this.document = options.document || (typeof(document) === "object" ? document : null);
// Hashmap of the renderer classes
if(!this.rendererClasses) {
WikiRenderTree.prototype.rendererClasses = $tw.modules.applyMethods("wikirenderer");
@@ -64,19 +66,6 @@ WikiRenderTree.prototype.createRenderer = function(parentRenderer,parseTreeNode)
return new RenderNodeClass(this,parentRenderer,parseTreeNode);
};
/*
Render as a string
*/
WikiRenderTree.prototype.render = function(type) {
var output = [];
$tw.utils.each(this.rendererTree,function(node) {
if(node.render) {
output.push(node.render(type));
}
});
return output.join("");
};
/*
Render to the DOM
*/