mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-09-14 00:09:42 +00:00
40 lines
935 B
JavaScript
40 lines
935 B
JavaScript
|
/*\
|
||
|
title: $:/core/modules/widgets/view/viewers/htmlencoded.js
|
||
|
type: application/javascript
|
||
|
module-type: newfieldviewer
|
||
|
|
||
|
A viewer for viewing tiddler fields as HTML encoded text
|
||
|
|
||
|
\*/
|
||
|
(function(){
|
||
|
|
||
|
/*jslint node: true, browser: true */
|
||
|
/*global $tw: false */
|
||
|
"use strict";
|
||
|
|
||
|
var HtmlEncodedViewer = function(viewWidget,tiddler,field,value) {
|
||
|
this.viewWidget = viewWidget;
|
||
|
this.tiddler = tiddler;
|
||
|
this.field = field;
|
||
|
this.value = value;
|
||
|
};
|
||
|
|
||
|
HtmlEncodedViewer.prototype.render = function() {
|
||
|
// Get the value as a string
|
||
|
if(this.field !== "text" && this.tiddler) {
|
||
|
this.value = this.tiddler.getFieldString(this.field);
|
||
|
}
|
||
|
var value = "";
|
||
|
if(this.value !== undefined && this.value !== null) {
|
||
|
value = this.value;
|
||
|
}
|
||
|
return this.viewWidget.renderer.renderTree.createRenderers(this.viewWidget.renderer.renderContext,[{
|
||
|
type: "text",
|
||
|
text: $tw.utils.htmlEncode(value)
|
||
|
}]);
|
||
|
};
|
||
|
|
||
|
exports.htmlencoded = HtmlEncodedViewer;
|
||
|
|
||
|
})();
|