1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2026-05-06 21:51:31 +00:00

Compare commits

...

5 Commits

Author SHA1 Message Date
saqimtiaz
f76ec0b2c6 fix: whitespace 2026-03-24 14:51:18 +01:00
saqimtiaz
69005a904d fix: restore mistakenly commited files 2026-03-24 14:48:55 +01:00
saqimtiaz
ed33625407 tests: added missing test 2026-03-24 14:45:41 +01:00
saqimtiaz
f848d8c368 wip: non-existent variables as attributes should be undefined 2026-03-24 14:41:43 +01:00
saqimtiaz
729d4b6374 wip: non-existent variables as attributes should be undefined 2026-03-24 14:13:31 +01:00
3 changed files with 17 additions and 4 deletions

View File

@@ -61,7 +61,7 @@ LogWidget.prototype.log = function() {
$tw.utils.each(this.parseTreeNode.attributes,function(attribute,name) {
if(name.substring(0,2) !== "$$") {
var resultList = self.computeAttribute(attribute,{asList: true});
if(resultList.length <= 1) {
if(resultList && resultList.length <= 1) {
data[name] = resultList[0] || "";
} else {
data[name] = resultList;
@@ -75,7 +75,7 @@ LogWidget.prototype.log = function() {
allVars[v] = variable.value;
} else {
var variableInfo = this.getVariableInfo(v);
allVars[v] = variableInfo.resultList.length > 1 ? variableInfo.resultList : variableInfo.text;
allVars[v] = variableInfo && variableInfo.resultList && variableInfo.resultList.length > 1 ? variableInfo.resultList : variableInfo.text;
}
}
if(this.filter) {

View File

@@ -189,7 +189,7 @@ Widget.prototype.getVariableInfo = function(name,options) {
}
return {
text: text,
resultList: [text]
resultList: text === undefined ? text : [text]
};
};
@@ -338,7 +338,7 @@ Widget.prototype.makeFakeWidgetWithVariables = function(vars = {}) {
const value = vars[name];
return Array.isArray(value)
? { text: value[0], resultList: value }
: { text: value, resultList: [value] };
: { text: value, resultList: value === undefined ? value : [value] };
}
opts = opts || {};
opts.variables = Object.assign({}, vars, opts.variables || {});

View File

@@ -0,0 +1,13 @@
title: Transclude/MissingTiddlerAttributeVariable
description: Missing Tiddler Attribute Variable
type: text/vnd.tiddlywiki-multiple
tags: [[$:/tags/wiki-test-spec]]
title: Output
description: hello
<$transclude tiddler=<<nonExistentVariable>> field="description"/>
+
title: ExpectedResult
<p>hello</p>