mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-17 23:34:50 +00:00
Fix and test missing target handling
This commit is contained in:
parent
54b48876f7
commit
05b582a202
@ -47,22 +47,26 @@ UberTranscludeWidget.prototype.execute = function() {
|
|||||||
this.transcludeIndex = this.getAttribute("$index");
|
this.transcludeIndex = this.getAttribute("$index");
|
||||||
this.transcludeMode = this.getAttribute("$mode");
|
this.transcludeMode = this.getAttribute("$mode");
|
||||||
this.recursionMarker = this.getAttribute("$recursionMarker","yes");
|
this.recursionMarker = this.getAttribute("$recursionMarker","yes");
|
||||||
// Find the value widgets in our parse tree
|
// Find the value widgets in our child parse tree
|
||||||
this.slotValueParseTrees = Object.create(null);
|
this.slotValueParseTrees = Object.create(null);
|
||||||
this.slotValueParseTrees.missing = this.parseTreeNode.children;
|
var noValueWidgetsFound = true,
|
||||||
var searchParseTreeNodes = function(nodes) {
|
searchParseTreeNodes = function(nodes) {
|
||||||
$tw.utils.each(nodes,function(node) {
|
$tw.utils.each(nodes,function(node) {
|
||||||
if(node.type === "value" && node.tag === "$value") {
|
if(node.type === "value" && node.tag === "$value") {
|
||||||
if(node.attributes["$name"] && node.attributes["$name"].type === "string") {
|
if(node.attributes["$name"] && node.attributes["$name"].type === "string") {
|
||||||
var slotValueName = node.attributes["$name"].value;
|
var slotValueName = node.attributes["$name"].value;
|
||||||
self.slotValueParseTrees[slotValueName] = node.children;
|
self.slotValueParseTrees[slotValueName] = node.children;
|
||||||
}
|
}
|
||||||
|
noValueWidgetsFound = false;
|
||||||
} else {
|
} else {
|
||||||
searchParseTreeNodes(node.children);
|
searchParseTreeNodes(node.children);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
searchParseTreeNodes(this.parseTreeNode.children);
|
searchParseTreeNodes(this.parseTreeNode.children);
|
||||||
|
if(noValueWidgetsFound) {
|
||||||
|
this.slotValueParseTrees["missing"] = this.parseTreeNode.children;
|
||||||
|
}
|
||||||
// Parse the text reference
|
// Parse the text reference
|
||||||
var parseAsInline = !this.parseTreeNode.isBlock;
|
var parseAsInline = !this.parseTreeNode.isBlock;
|
||||||
if(this.transcludeMode === "inline") {
|
if(this.transcludeMode === "inline") {
|
||||||
@ -83,7 +87,7 @@ UberTranscludeWidget.prototype.execute = function() {
|
|||||||
subTiddler: this.transcludeSubTiddler
|
subTiddler: this.transcludeSubTiddler
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
var parseTreeNodes = parser ? parser.tree : this.parseTreeNode.children;
|
var parseTreeNodes = parser ? parser.tree : (this.slotValueParseTrees["missing"] || []);
|
||||||
this.sourceText = parser ? parser.source : null;
|
this.sourceText = parser ? parser.source : null;
|
||||||
this.parserType = parser? parser.type : null;
|
this.parserType = parser? parser.type : null;
|
||||||
// Set context variables for recursion detection
|
// Set context variables for recursion detection
|
||||||
|
@ -0,0 +1,48 @@
|
|||||||
|
title: Ubertransclude/MissingTarget
|
||||||
|
description: Transcluding a missing target
|
||||||
|
type: text/vnd.tiddlywiki-multiple
|
||||||
|
tags: [[$:/tags/wiki-test-spec]]
|
||||||
|
|
||||||
|
title: Output
|
||||||
|
|
||||||
|
\whitespace trim
|
||||||
|
<$ubertransclude $tiddler='TiddlerOne' one='Ferret'>
|
||||||
|
<$parameters one='Ferret'>
|
||||||
|
Badger
|
||||||
|
<$text text=<<one>>/>
|
||||||
|
</$parameters>
|
||||||
|
</$ubertransclude>
|
||||||
|
<$ubertransclude $tiddler='TiddlerOne' one='Ferret'>
|
||||||
|
<$value $name="missing">
|
||||||
|
<$parameters one='Ferret'>
|
||||||
|
Badger
|
||||||
|
<$text text=<<one>>/>
|
||||||
|
</$parameters>
|
||||||
|
</$value>
|
||||||
|
</$ubertransclude>
|
||||||
|
<$ubertransclude $tiddler='MissingTiddler' one='Ferret'>
|
||||||
|
<$parameters one='Ferret'>
|
||||||
|
Badger
|
||||||
|
<$text text=<<one>>/>
|
||||||
|
</$parameters>
|
||||||
|
</$ubertransclude>
|
||||||
|
<$ubertransclude $tiddler='MissingTiddler' one='Ferret'>
|
||||||
|
<$value $name="missing">
|
||||||
|
<$parameters one='Ferret'>
|
||||||
|
Badger
|
||||||
|
<$text text=<<one>>/>
|
||||||
|
</$parameters>
|
||||||
|
</$value>
|
||||||
|
</$ubertransclude>
|
||||||
|
_
|
||||||
|
title: TiddlerOne
|
||||||
|
|
||||||
|
\whitespace trim
|
||||||
|
<$parameters one='Kangaroo'>
|
||||||
|
Piranha
|
||||||
|
<$text text=<<one>>/>
|
||||||
|
</$parameters>
|
||||||
|
_
|
||||||
|
title: ExpectedResult
|
||||||
|
|
||||||
|
<p>PiranhaFerretPiranhaFerretBadgerFerretBadgerFerret</p>
|
Loading…
Reference in New Issue
Block a user