mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-01-18 13:12:52 +00:00
fix: only fallback to title when {{!!xxx}}, not when input is empty
This commit is contained in:
parent
30dae0c60d
commit
967657c6dd
@ -564,18 +564,23 @@ exports.extractTranscludes = function(parseTreeRoot, title) {
|
|||||||
var value;
|
var value;
|
||||||
// if it is Transclusion with Templates like `{{Index||$:/core/ui/TagTemplate}}`, the `$tiddler` will point to the template. We need to find the actual target tiddler from parent node
|
// if it is Transclusion with Templates like `{{Index||$:/core/ui/TagTemplate}}`, the `$tiddler` will point to the template. We need to find the actual target tiddler from parent node
|
||||||
if(parentNode && parentNode.type === "tiddler" && parentNode.attributes.tiddler && parentNode.attributes.tiddler.type === "string") {
|
if(parentNode && parentNode.type === "tiddler" && parentNode.attributes.tiddler && parentNode.attributes.tiddler.type === "string") {
|
||||||
value = parentNode.attributes.tiddler.value;
|
// Empty value (like `{{!!field}}`) means self-referential transclusion.
|
||||||
|
value = parentNode.attributes.tiddler.value || title;
|
||||||
} else {
|
} else {
|
||||||
value = parseTreeNode.attributes.$tiddler.value;
|
value = parseTreeNode.attributes.$tiddler.value;
|
||||||
}
|
}
|
||||||
} else if(parseTreeNode.attributes.tiddler && parseTreeNode.attributes.tiddler.type === "string") {
|
} else if(parseTreeNode.attributes.tiddler && parseTreeNode.attributes.tiddler.type === "string") {
|
||||||
|
// Old transclude widget usage
|
||||||
value = parseTreeNode.attributes.tiddler.value;
|
value = parseTreeNode.attributes.tiddler.value;
|
||||||
}
|
} else if(parseTreeNode.attributes.$field && parseTreeNode.attributes.$field.type === "string") {
|
||||||
if (!value) {
|
// Empty value (like `<$transclude $field='created'/>`) means self-referential transclusion.
|
||||||
|
value = title;
|
||||||
|
} else if(parseTreeNode.attributes.field && parseTreeNode.attributes.field.type === "string") {
|
||||||
|
// Old usage with Empty value (like `<$transclude field='created'/>`)
|
||||||
value = title;
|
value = title;
|
||||||
}
|
}
|
||||||
// Empty value (like `{{!!field}}`) means self-referential transclusion. Also deduplicate the result.
|
// Deduplicate the result.
|
||||||
if(transcludes.indexOf(value) === -1) {
|
if(value && transcludes.indexOf(value) === -1) {
|
||||||
transcludes.push(value);
|
transcludes.push(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,9 @@ describe('Backtranscludes and transclude filter tests', function() {
|
|||||||
it('should have no backtranscludes', function() {
|
it('should have no backtranscludes', function() {
|
||||||
expect(wiki.filterTiddlers('TestIncoming +[backtranscludes[]]').join(',')).toBe('');
|
expect(wiki.filterTiddlers('TestIncoming +[backtranscludes[]]').join(',')).toBe('');
|
||||||
});
|
});
|
||||||
|
it('should have no transcludes', function() {
|
||||||
|
expect(wiki.filterTiddlers('TestIncoming +[transcludes[]]').join(',')).toBe('');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('A tiddler added to the wiki with a transclude to it', function() {
|
describe('A tiddler added to the wiki with a transclude to it', function() {
|
||||||
@ -38,6 +41,9 @@ describe('Backtranscludes and transclude filter tests', function() {
|
|||||||
it('should have a backtransclude', function() {
|
it('should have a backtransclude', function() {
|
||||||
expect(wiki.filterTiddlers('TestIncoming +[backtranscludes[]]').join(',')).toBe('TestOutgoing');
|
expect(wiki.filterTiddlers('TestIncoming +[backtranscludes[]]').join(',')).toBe('TestOutgoing');
|
||||||
});
|
});
|
||||||
|
it('should have a transclude', function() {
|
||||||
|
expect(wiki.filterTiddlers('TestOutgoing +[transcludes[]]').join(',')).toBe('TestIncoming');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('A tiddler transclude with template will still use the tiddler as result.', function() {
|
describe('A tiddler transclude with template will still use the tiddler as result.', function() {
|
||||||
|
Loading…
Reference in New Issue
Block a user