From 9c41fe1d182b0d87ae994dd38ab24b1d28c4f1df Mon Sep 17 00:00:00 2001 From: Cameron Fischer Date: Mon, 27 Sep 2021 09:23:52 -0400 Subject: [PATCH] JSONTiddler a little more extensible (#6057) As per discussion #6043 --- core/modules/widgets/jsontiddler.js | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/core/modules/widgets/jsontiddler.js b/core/modules/widgets/jsontiddler.js index 571d63f02..d40432e9f 100644 --- a/core/modules/widgets/jsontiddler.js +++ b/core/modules/widgets/jsontiddler.js @@ -32,13 +32,7 @@ JSONTiddlerWidget.prototype.render = function(parent,nextSibling) { this.computeAttributes(); this.execute(); // Collect the fields from the optional base tiddler - var fields = {}; - if(this.attTiddler) { - var tiddler = this.wiki.getTiddler(this.attTiddler); - if(tiddler) { - fields = tiddler.getFieldStrings({exclude: this.attExclude.split(" ")}); - } - } + var fields = this.getTiddlerFields(); // Add custom fields specified in attributes starting with $ $tw.utils.each(this.attributes,function(attribute,name) { if(name.charAt(0) === "$") { @@ -79,6 +73,17 @@ JSONTiddlerWidget.prototype.refresh = function(changedTiddlers) { } }; +JSONTiddlerWidget.prototype.getTiddlerFields = function() { + var fields = {}; + if(this.attTiddler) { + var tiddler = this.wiki.getTiddler(this.attTiddler); + if(tiddler) { + fields = tiddler.getFieldStrings({exclude: this.attExclude.split(" ")}); + } + } + return fields; +}; + exports.jsontiddler = JSONTiddlerWidget; })(); \ No newline at end of file