1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-06 01:56:20 +00:00
TiddlyWiki5/core/modules/rendertree/renderers/text.js
Jeremy Ruston 8564602256 Refactor rendertree to simplify context handling
Get rid of the separate renderContext stack and instead have a parent
pointer on renderer nodes. This lets us walk back up the render tree to
resolve context references
2013-05-15 17:32:17 +01:00

36 lines
755 B
JavaScript

/*\
title: $:/core/modules/rendertree/renderers/text.js
type: application/javascript
module-type: wikirenderer
Text renderer
\*/
(function(){
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
/*
Text renderer
*/
var TextRenderer = function(renderTree,parentRenderer,parseTreeNode) {
// Store state information
this.renderTree = renderTree;
this.parentRenderer = parentRenderer;
this.parseTreeNode = parseTreeNode;
};
TextRenderer.prototype.render = function(type) {
return type === "text/html" ? $tw.utils.htmlEncode(this.parseTreeNode.text) : this.parseTreeNode.text;
};
TextRenderer.prototype.renderInDom = function() {
return document.createTextNode(this.parseTreeNode.text);
};
exports.text = TextRenderer
})();