1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2026-01-25 20:33:41 +00:00

Compare commits

...

9 Commits

Author SHA1 Message Date
saqimtiaz
5797855aa1 Merge branch 'saqimtiaz-patch-1' of https://github.com/jermolene/TiddlyWiki5 into fix-defaults-functions 2026-01-25 19:15:15 +01:00
saqimtiaz
d3fded71c2 Merge branch 'master' into fix-defaults-functions 2026-01-25 19:13:53 +01:00
Saq Imtiaz
293dbca5a1 Update #8972.tid 2026-01-25 19:08:11 +01:00
saqimtiaz
4d1645d16d fix: correctly resolve default values for functions 2026-01-25 18:32:22 +01:00
Saq Imtiaz
b58c14b906 Update #8972.tid 2026-01-25 17:45:28 +01:00
Saq Imtiaz
ad5d3c3cde Update function default values in FunctionDefaultValues.tid 2026-01-25 17:37:17 +01:00
Saq Imtiaz
f0d8852121 Add FunctionDefaultValues test for default parameters 2026-01-25 17:35:12 +01:00
Saq Imtiaz
48c6694d30 Enhance release notes for version 5.4.0
Updated GitHub links and contributors for release notes.
2026-01-25 17:30:35 +01:00
Saq Imtiaz
a993cea80c Fix: bug in multivalue default params 2026-01-25 17:28:22 +01:00
3 changed files with 23 additions and 5 deletions

View File

@@ -160,7 +160,7 @@ Widget.prototype.getVariableInfo = function(name,options) {
});
// Parameters are an array of {name:, value:, multivalue:} pairs (name and multivalue are optional)
$tw.utils.each(params,function(param) {
if(param.multiValue) {
if(param.multiValue && param.multiValue.length) {
variables[param.name] = param.multiValue;
} else {
variables[param.name] = param.value || "";
@@ -233,8 +233,10 @@ Widget.prototype.resolveVariableParameters = function(formalParams,actualParams)
paramMultiValue = typeof param === "string" ? [param] : (param.multiValue || [paramValue]);
}
// If we've still not got a value, use the default, if any
paramValue = paramValue || paramInfo["default"] || "";
paramMultiValue = paramMultiValue || [paramValue];
if(!paramValue) {
paramValue = paramInfo["default"] || "";
paramMultiValue = [paramValue];
}
// Store the parameter name and value
results.push({name: paramInfo.name, value: paramValue, multiValue: paramMultiValue});
}

View File

@@ -0,0 +1,16 @@
title: Functions/FunctionDefaultValues
description: Use defaults for missing parameters in functions in filters
type: text/vnd.tiddlywiki-multiple
tags: [[$:/tags/wiki-test-spec]]
title: Output
\whitespace trim
\function .test(prefix:Default) [[ Content]addprefix<prefix>]
<$text text={{{ [.test[Special]] }}}/>,<$text text={{{ [.test[]] }}}/>
+
title: ExpectedResult
<p>Special Content,Default Content</p>

View File

@@ -4,8 +4,8 @@ release: 5.4.0
tags: $:/tags/ChangeNote
change-type: enhancement
change-category: hackability
github-links: https://github.com/TiddlyWiki/TiddlyWiki5/pull/8972
github-contributors: Jermolene
github-links: https://github.com/TiddlyWiki/TiddlyWiki5/pull/8972 https://github.com/TiddlyWiki/TiddlyWiki5/pull/9614
github-contributors: Jermolene saqimtiaz
This PR introduces a new filter run prefix `:let` that assigns the result of the filter run to a variable that is made available for the remaining filter runs of the filter expression. It solves the problem that previously it was impossible to compute values for filter operator parameters; parameters could only be a literal string, text reference or variable reference.