1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-06-25 23:03:15 +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:
Jermolene 2014-02-12 21:38:37 +00:00
parent b5225f5ca8
commit ca0c352278
3 changed files with 8 additions and 5 deletions

View File

@ -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);
};

View File

@ -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);
}
}

View File

@ -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