mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-01-31 03:14:49 +00:00
feat: support old <$transclude tiddler param
This commit is contained in:
parent
78d1bd1570
commit
a3bf9c0f1c
@ -559,7 +559,8 @@ exports.extractTranscludes = function(parseTreeRoot, title) {
|
|||||||
checkParseTree = function(parseTree, parentNode) {
|
checkParseTree = function(parseTree, parentNode) {
|
||||||
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" && parseTreeNode.attributes.$tiddler && parseTreeNode.attributes.$tiddler.type === "string") {
|
if(parseTreeNode.type === "transclude") {
|
||||||
|
if(parseTreeNode.attributes.$tiddler && parseTreeNode.attributes.$tiddler.type === "string") {
|
||||||
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") {
|
||||||
@ -567,6 +568,9 @@ exports.extractTranscludes = function(parseTreeRoot, title) {
|
|||||||
} else {
|
} else {
|
||||||
value = parseTreeNode.attributes.$tiddler.value;
|
value = parseTreeNode.attributes.$tiddler.value;
|
||||||
}
|
}
|
||||||
|
} else if(parseTreeNode.attributes.tiddler && parseTreeNode.attributes.tiddler.type === "string") {
|
||||||
|
value = parseTreeNode.attributes.tiddler.value;
|
||||||
|
}
|
||||||
// ignore empty value (like `{{!!field}}`), and deduplicate
|
// ignore empty value (like `{{!!field}}`), and deduplicate
|
||||||
if(value && transcludes.indexOf(value) === -1 && value !== title) {
|
if(value && transcludes.indexOf(value) === -1 && value !== title) {
|
||||||
transcludes.push(value);
|
transcludes.push(value);
|
||||||
|
@ -219,14 +219,15 @@ describe('Backtranscludes and transclude filter tests', function() {
|
|||||||
|
|
||||||
wiki.addTiddler({
|
wiki.addTiddler({
|
||||||
title: 'TestOutgoing',
|
title: 'TestOutgoing',
|
||||||
text: "<$tiddler tiddler='TestIncoming'><$transclude $tiddler /></$tiddler>"});
|
text: "<$tiddler tiddler='TestIncoming'><$transclude $tiddler /></$tiddler>\n\n<$transclude tiddler='TiddlyWiki Pre-release'/>"});
|
||||||
|
|
||||||
it('should have a transclude', function() {
|
it('should have a transclude', function() {
|
||||||
expect(wiki.filterTiddlers('TestOutgoing +[transcludes[]]').join(',')).toBe('TestIncoming');
|
expect(wiki.filterTiddlers('TestOutgoing +[transcludes[]]').join(',')).toBe('TestIncoming,TiddlyWiki Pre-release');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should have a back transclude', function() {
|
it('should have a back transclude', function() {
|
||||||
expect(wiki.filterTiddlers('TestIncoming +[backtranscludes[]]').join(',')).toBe('TestOutgoing');
|
expect(wiki.filterTiddlers('TestIncoming +[backtranscludes[]]').join(',')).toBe('TestOutgoing');
|
||||||
|
expect(wiki.filterTiddlers('[[TiddlyWiki Pre-release]] +[backtranscludes[]]').join(',')).toBe('TestOutgoing');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user