mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-10 03:49:56 +00:00
Fix for minor transclude wikimethod issue (#8382)
This commit is contained in:
parent
da697f1a5b
commit
a3a9fd3931
@ -560,18 +560,22 @@ exports.extractTranscludes = function(parseTreeRoot, title) {
|
|||||||
for(var t=0; t<parseTree.length; t++) {
|
for(var t=0; t<parseTree.length; t++) {
|
||||||
var parseTreeNode = parseTree[t];
|
var parseTreeNode = parseTree[t];
|
||||||
if(parseTreeNode.type === "transclude") {
|
if(parseTreeNode.type === "transclude") {
|
||||||
if(parseTreeNode.attributes.$tiddler && parseTreeNode.attributes.$tiddler.type === "string") {
|
if(parseTreeNode.attributes.$tiddler) {
|
||||||
var value;
|
if(parseTreeNode.attributes.$tiddler.type === "string") {
|
||||||
// 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
|
var value;
|
||||||
if(parentNode && parentNode.type === "tiddler" && parentNode.attributes.tiddler && parentNode.attributes.tiddler.type === "string") {
|
// 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
|
||||||
// Empty value (like `{{!!field}}`) means self-referential transclusion.
|
if(parentNode && parentNode.type === "tiddler" && parentNode.attributes.tiddler && parentNode.attributes.tiddler.type === "string") {
|
||||||
value = parentNode.attributes.tiddler.value || title;
|
// Empty value (like `{{!!field}}`) means self-referential transclusion.
|
||||||
} else {
|
value = parentNode.attributes.tiddler.value || title;
|
||||||
value = parseTreeNode.attributes.$tiddler.value;
|
} else {
|
||||||
|
value = parseTreeNode.attributes.$tiddler.value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if(parseTreeNode.attributes.tiddler) {
|
||||||
|
if (parseTreeNode.attributes.tiddler.type === "string") {
|
||||||
|
// Old transclude widget usage
|
||||||
|
value = parseTreeNode.attributes.tiddler.value;
|
||||||
}
|
}
|
||||||
} else if(parseTreeNode.attributes.tiddler && parseTreeNode.attributes.tiddler.type === "string") {
|
|
||||||
// Old transclude widget usage
|
|
||||||
value = parseTreeNode.attributes.tiddler.value;
|
|
||||||
} else if(parseTreeNode.attributes.$field && parseTreeNode.attributes.$field.type === "string") {
|
} else if(parseTreeNode.attributes.$field && parseTreeNode.attributes.$field.type === "string") {
|
||||||
// Empty value (like `<$transclude $field='created'/>`) means self-referential transclusion.
|
// Empty value (like `<$transclude $field='created'/>`) means self-referential transclusion.
|
||||||
value = title;
|
value = title;
|
||||||
|
@ -220,6 +220,22 @@ describe('Backtranscludes and transclude filter tests', function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('exclude self when target tiddler is not string', function() {
|
||||||
|
var wiki = new $tw.Wiki();
|
||||||
|
|
||||||
|
wiki.addTiddler({
|
||||||
|
title: 'TestOutgoing',
|
||||||
|
text: "<$transclude $tiddler={{TestOutgoing!!title}} $field='created'/> and <$transclude tiddler={{TestOutgoing!!title}} field='created'/>"});
|
||||||
|
|
||||||
|
it('should have no transclude', function() {
|
||||||
|
expect(wiki.filterTiddlers('TestOutgoing +[transcludes[]]').join(',')).toBe('');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should have no back transcludes', function() {
|
||||||
|
expect(wiki.filterTiddlers('TestOutgoing +[backtranscludes[]]').join(',')).toBe('');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('recognize transclusion defined by widget', function() {
|
describe('recognize transclusion defined by widget', function() {
|
||||||
var wiki = new $tw.Wiki();
|
var wiki = new $tw.Wiki();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user