1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-07-02 02:03:14 +00:00

Refactor parse mode out of getTransclusionTarget

This commit is contained in:
Jeremy Ruston 2023-07-27 18:39:59 +01:00
parent c1ff85c205
commit c4fc3168d1

View File

@ -41,8 +41,15 @@ TranscludeWidget.prototype.execute = function() {
this.collectAttributes(); this.collectAttributes();
this.collectStringParameters(); this.collectStringParameters();
this.collectSlotFillParameters(); this.collectSlotFillParameters();
// Determine whether we're being used in inline or block mode
var parseAsInline = !this.parseTreeNode.isBlock;
if(this.transcludeMode === "inline") {
parseAsInline = true;
} else if(this.transcludeMode === "block") {
parseAsInline = false;
}
// Get the target text and parse tree nodes that we are transcluding // Get the target text and parse tree nodes that we are transcluding
var target = this.getTransclusionTarget(), var target = this.getTransclusionTarget(parseAsInline),
parseTreeNodes; parseTreeNodes;
this.sourceText = target.text; this.sourceText = target.text;
this.parserType = target.type; this.parserType = target.type;
@ -163,15 +170,8 @@ TranscludeWidget.prototype.collectSlotFillParameters = function() {
/* /*
Get transcluded parse tree nodes as an object {text:,type:,parseTreeNodes:,parseAsInline:} Get transcluded parse tree nodes as an object {text:,type:,parseTreeNodes:,parseAsInline:}
*/ */
TranscludeWidget.prototype.getTransclusionTarget = function() { TranscludeWidget.prototype.getTransclusionTarget = function(parseAsInline) {
var self = this; var self = this;
// Determine whether we're being used in inline or block mode
var parseAsInline = !this.parseTreeNode.isBlock;
if(this.transcludeMode === "inline") {
parseAsInline = true;
} else if(this.transcludeMode === "block") {
parseAsInline = false;
}
var parser; var parser;
// Get the parse tree // Get the parse tree
if(this.hasAttribute("$variable")) { if(this.hasAttribute("$variable")) {