mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-23 18:17:20 +00:00
Extend the transclude widget to fallback to displaying it's child nodes if the target isn't defined
This commit is contained in:
parent
b5225f5ca8
commit
ca0c352278
@ -62,7 +62,7 @@ TranscludeWidget.prototype.execute = function() {
|
||||
this.transcludeField,
|
||||
this.transcludeIndex,
|
||||
{parseAsInline: parseAsInline}),
|
||||
parseTreeNodes = parser ? parser.tree : [];
|
||||
parseTreeNodes = parser ? parser.tree : this.parseTreeNode.children;
|
||||
// Construct the child widgets
|
||||
this.makeChildWidgets(parseTreeNodes);
|
||||
};
|
||||
|
@ -789,13 +789,16 @@ exports.parseTextReference = function(title,field,index,options) {
|
||||
var tiddler,text;
|
||||
if(field) {
|
||||
tiddler = this.getTiddler(title);
|
||||
text = tiddler ? tiddler.fields[field] : "";
|
||||
if(text === undefined) {
|
||||
text = "";
|
||||
if(!tiddler || !tiddler.hasField(field)) {
|
||||
return null;
|
||||
}
|
||||
text = tiddler.fields[field];
|
||||
return this.parseText("text/vnd.tiddlywiki",text.toString(),options);
|
||||
} else if(index) {
|
||||
text = this.extractTiddlerDataItem(title,index,"");
|
||||
if(text === undefined) {
|
||||
return null;
|
||||
}
|
||||
return this.parseText("text/vnd.tiddlywiki",text,options);
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ The TranscludeWidget dynamically imports content from another tiddler.
|
||||
|tooltip |Tooltip to be added to the generated elements |
|
||||
|mode |Override the default parsing mode for the transcluded text to "block" or "inline" |
|
||||
|
||||
The TranscludeWidget ignores any contained content.
|
||||
The TranscludeWidget treats any contained content as a fallback if the target of the transclusion is not defined (ie a missing tiddler or a missing field).
|
||||
|
||||
! Parsing modes
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user