mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-07-12 23:12:49 +00:00
Transclude widget should use fallback content if variable is missing or blank
Fixes #7424
This commit is contained in:
parent
db6b4f17e8
commit
8aa0db59a3
@ -51,7 +51,8 @@ MacroCallWidget.prototype.execute = function() {
|
|||||||
var positionalName = 0,
|
var positionalName = 0,
|
||||||
parseTreeNodes = [{
|
parseTreeNodes = [{
|
||||||
type: "transclude",
|
type: "transclude",
|
||||||
isBlock: this.parseTreeNode.isBlock
|
isBlock: this.parseTreeNode.isBlock,
|
||||||
|
children: this.parseTreeNode.children
|
||||||
}];
|
}];
|
||||||
$tw.utils.addAttributeToParseTreeNode(parseTreeNodes[0],"$variable",this.macroName);
|
$tw.utils.addAttributeToParseTreeNode(parseTreeNodes[0],"$variable",this.macroName);
|
||||||
$tw.utils.addAttributeToParseTreeNode(parseTreeNodes[0],"$type",this.parseType);
|
$tw.utils.addAttributeToParseTreeNode(parseTreeNodes[0],"$type",this.parseType);
|
||||||
|
@ -171,11 +171,12 @@ TranscludeWidget.prototype.getTransclusionTarget = function() {
|
|||||||
}
|
}
|
||||||
var parser;
|
var parser;
|
||||||
// Get the parse tree
|
// Get the parse tree
|
||||||
|
if(this.hasAttribute("$variable")) {
|
||||||
if(this.transcludeVariable) {
|
if(this.transcludeVariable) {
|
||||||
// Transcluding a variable
|
// Transcluding a variable
|
||||||
var variableInfo = this.getVariableInfo(this.transcludeVariable,{params: this.getOrderedTransclusionParameters()}),
|
var variableInfo = this.getVariableInfo(this.transcludeVariable,{params: this.getOrderedTransclusionParameters()}),
|
||||||
srcVariable = variableInfo && variableInfo.srcVariable;
|
srcVariable = variableInfo && variableInfo.srcVariable;
|
||||||
if(srcVariable) {
|
if(variableInfo.text) {
|
||||||
if(srcVariable.isFunctionDefinition) {
|
if(srcVariable.isFunctionDefinition) {
|
||||||
// Function to return parameters by name or position
|
// Function to return parameters by name or position
|
||||||
var fnGetParam = function(name,index) {
|
var fnGetParam = function(name,index) {
|
||||||
@ -267,6 +268,7 @@ TranscludeWidget.prototype.getTransclusionTarget = function() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// Transcluding a text reference
|
// Transcluding a text reference
|
||||||
parser = this.wiki.parseTextReference(
|
parser = this.wiki.parseTextReference(
|
||||||
|
@ -0,0 +1,40 @@
|
|||||||
|
title: Transclude/Macro/Missing
|
||||||
|
description: Transcluding a missing or blank variable
|
||||||
|
type: text/vnd.tiddlywiki-multiple
|
||||||
|
tags: [[$:/tags/wiki-test-spec]]
|
||||||
|
|
||||||
|
title: Output
|
||||||
|
|
||||||
|
\whitespace trim
|
||||||
|
<$macrocall $name="missingmacro">
|
||||||
|
Fallback content
|
||||||
|
</$macrocall>
|
||||||
|
|
||||||
|
<$transclude $variable="missingmacro">
|
||||||
|
Fallback content
|
||||||
|
</$transclude>
|
||||||
|
|
||||||
|
<$macrocall $name="">
|
||||||
|
Fallback content
|
||||||
|
</$macrocall>
|
||||||
|
|
||||||
|
<$transclude $variable="">
|
||||||
|
Fallback content
|
||||||
|
</$transclude>
|
||||||
|
|
||||||
|
<$let emptyVariable="">
|
||||||
|
|
||||||
|
<$macrocall $name="emptyVariable">
|
||||||
|
Fallback content
|
||||||
|
</$macrocall>
|
||||||
|
|
||||||
|
<$transclude $variable="emptyVariable">
|
||||||
|
Fallback content
|
||||||
|
</$transclude>
|
||||||
|
|
||||||
|
</$let>
|
||||||
|
|
||||||
|
+
|
||||||
|
title: ExpectedResult
|
||||||
|
|
||||||
|
<p>Fallback content</p><p>Fallback content</p><p>Fallback content</p><p>Fallback content</p><p>Fallback content</p><p>Fallback content</p>
|
Loading…
x
Reference in New Issue
Block a user