1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2026-02-09 19:50:22 +00:00

Compare commits

..

8 Commits

Author SHA1 Message Date
Jeremy Ruston
15f74118a6 Fix linting errors 2026-02-08 21:59:02 +00:00
Jeremy Ruston
bddd7bab17 Update change note 2026-02-08 21:55:48 +00:00
Jeremy Ruston
c0dd429274 Revert "Create pr-draft.md"
This reverts commit dd116af41b.
2026-02-08 21:49:45 +00:00
Jeremy Ruston
dd116af41b Create pr-draft.md 2026-02-08 21:48:25 +00:00
Jeremy Ruston
50ec0dd4b6 Add ((var)) syntax for passing multi-valued variables through transclude pipeline
Introduce ((var)) attribute syntax to explicitly pass
MVVs to procedures and functions via $transclude, solving the limitation
where <<var>> always resolves to the first value only for backwards
compatibility. Also adds ((var||sep)) and (((filter||sep))) inline display
syntax for debugging MVV values, and multivalued defaults for parameter attributes
2026-02-08 21:46:18 +00:00
Théophile Desmedt
0177f09823 Implement translations and indentation fixes for Advanced Info tab (#9643)
* Implement translations and indentation fixes for Advanced Info tab

* update change note

* Update CascadeInfo hint for current tiddler context

Clarified hint for cascade info in TiddlerInfo.

* docs: update github-links in release note #9634
2026-02-08 11:50:12 +01:00
Jeremy Ruston
643cabf9c8 Additional docs for #9641 2026-02-06 16:33:29 +00:00
Jeremy Ruston
5cf3fcd843 Background actions and media query tracking (#9641)
* Initial commit cherry picked from #8702

* Initial docs from #8702

...which need to also be turned into a changenote

* Add changenote
2026-02-06 16:30:46 +00:00
25 changed files with 518 additions and 72 deletions

View File

@@ -10,6 +10,10 @@ Advanced/ShadowInfo/Shadow/Hint: The tiddler <$link to=<<infoTiddler>>><$text te
Advanced/ShadowInfo/Shadow/Source: It is defined in the plugin <$link to=<<pluginTiddler>>><$text text=<<pluginTiddler>>/></$link>
Advanced/ShadowInfo/OverriddenShadow/Hint: It is overridden by an ordinary tiddler
Advanced/CascadeInfo/Heading: Cascade Details
Advanced/CascadeInfo/Hint: These are the view template segments (tagged <<tag "$:/tags/ViewTemplate">>) using a cascade filter and their resulting template for the current tiddler.
Advanced/CascadeInfo/Detail/View: View
Advanced/CascadeInfo/Detail/ActiveCascadeFilter: Active cascade filter
Advanced/CascadeInfo/Detail/Template: Template
Fields/Caption: Fields
List/Caption: List
List/Empty: This tiddler does not have a list

View File

@@ -143,7 +143,14 @@ exports.parseParameterDefinition = function(paramString,options) {
var paramInfo = {name: paramMatch[1]},
defaultValue = paramMatch[2] || paramMatch[3] || paramMatch[4] || paramMatch[5];
if(defaultValue !== undefined) {
paramInfo["default"] = defaultValue;
// Check for an MVV reference ((varname))
var mvvDefaultMatch = /^\(\(([^)|]+)\)\)$/.exec(defaultValue);
if(mvvDefaultMatch) {
paramInfo.defaultType = "multivalue-variable";
paramInfo.defaultVariable = mvvDefaultMatch[1];
} else {
paramInfo["default"] = defaultValue;
}
}
params.push(paramInfo);
// Look for the next parameter
@@ -247,6 +254,46 @@ exports.parseMacroInvocationAsTransclusion = function(source,pos) {
return node;
};
/*
Look for an MVV (multi-valued variable) reference as a transclusion, i.e. ((varname)) or ((varname params))
Returns null if not found, or a parse tree node of type "transclude" with isMVV: true
*/
exports.parseMVVReferenceAsTransclusion = function(source,pos) {
var node = {
type: "transclude",
isMVV: true,
start: pos,
attributes: {},
orderedAttributes: []
};
// Define our regexps
var reVarName = /([^\s>"'=:)]+)/g;
// Skip whitespace
pos = $tw.utils.skipWhiteSpace(source,pos);
// Look for a double opening parenthesis
var token = $tw.utils.parseTokenString(source,pos,"((");
if(!token) {
return null;
}
pos = token.end;
// Get the variable name
token = $tw.utils.parseTokenRegExp(source,pos,reVarName);
if(!token) {
return null;
}
$tw.utils.addAttributeToParseTreeNode(node,"$variable",token.match[1]);
pos = token.end;
// Skip whitespace
pos = $tw.utils.skipWhiteSpace(source,pos);
// Look for a double closing parenthesis
token = $tw.utils.parseTokenString(source,pos,"))");
if(!token) {
return null;
}
node.end = token.end;
return node;
};
/*
Parse macro parameters as attributes. Returns the position after the last attribute
*/
@@ -321,19 +368,20 @@ exports.parseMacroParameterAsAttribute = function(source,pos) {
node.type = "indirect";
node.textReference = indirectValue.match[1];
} else {
// Look for a unquoted value
var unquotedValue = $tw.utils.parseTokenRegExp(source,pos,reUnquotedAttribute);
if(unquotedValue) {
pos = unquotedValue.end;
node.type = "string";
node.value = unquotedValue.match[1];
// Look for a macro invocation value
var macroInvocation = $tw.utils.parseMacroInvocationAsTransclusion(source,pos);
if(macroInvocation && isNewStyleSeparator) {
pos = macroInvocation.end;
node.type = "macro";
node.value = macroInvocation;
} else {
// Look for a macro invocation value
var macroInvocation = $tw.utils.parseMacroInvocationAsTransclusion(source,pos);
if(macroInvocation && isNewStyleSeparator) {
pos = macroInvocation.end;
// Look for an MVV reference value
var mvvReference = $tw.utils.parseMVVReferenceAsTransclusion(source,pos);
if(mvvReference && isNewStyleSeparator) {
pos = mvvReference.end;
node.type = "macro";
node.value = macroInvocation;
node.value = mvvReference;
node.isMVV = true;
} else {
var substitutedValue = $tw.utils.parseTokenRegExp(source,pos,reSubstitutedValue);
if(substitutedValue && isNewStyleSeparator) {
@@ -341,6 +389,14 @@ exports.parseMacroParameterAsAttribute = function(source,pos) {
node.type = "substituted";
node.rawValue = substitutedValue.match[1] || substitutedValue.match[2];
} else {
// Look for a unquoted value
var unquotedValue = $tw.utils.parseTokenRegExp(source,pos,reUnquotedAttribute);
if(unquotedValue) {
pos = unquotedValue.end;
node.type = "string";
node.value = unquotedValue.match[1];
} else {
}
}
}
}
@@ -471,19 +527,20 @@ exports.parseAttribute = function(source,pos) {
node.type = "indirect";
node.textReference = indirectValue.match[1];
} else {
// Look for a unquoted value
var unquotedValue = $tw.utils.parseTokenRegExp(source,pos,reUnquotedAttribute);
if(unquotedValue) {
pos = unquotedValue.end;
node.type = "string";
node.value = unquotedValue.match[1];
// Look for a macro invocation value
var macroInvocation = $tw.utils.parseMacroInvocationAsTransclusion(source,pos);
if(macroInvocation) {
pos = macroInvocation.end;
node.type = "macro";
node.value = macroInvocation;
} else {
// Look for a macro invocation value
var macroInvocation = $tw.utils.parseMacroInvocationAsTransclusion(source,pos);
if(macroInvocation) {
pos = macroInvocation.end;
// Look for an MVV reference value
var mvvReference = $tw.utils.parseMVVReferenceAsTransclusion(source,pos);
if(mvvReference) {
pos = mvvReference.end;
node.type = "macro";
node.value = macroInvocation;
node.value = mvvReference;
node.isMVV = true;
} else {
var substitutedValue = $tw.utils.parseTokenRegExp(source,pos,reSubstitutedValue);
if(substitutedValue) {
@@ -491,8 +548,16 @@ exports.parseAttribute = function(source,pos) {
node.type = "substituted";
node.rawValue = substitutedValue.match[1] || substitutedValue.match[2];
} else {
node.type = "string";
node.value = "true";
// Look for a unquoted value
var unquotedValue = $tw.utils.parseTokenRegExp(source,pos,reUnquotedAttribute);
if(unquotedValue) {
pos = unquotedValue.end;
node.type = "string";
node.value = unquotedValue.match[1];
} else {
node.type = "string";
node.value = "true";
}
}
}
}

View File

@@ -32,7 +32,7 @@ Instantiate parse rule
exports.init = function(parser) {
this.parser = parser;
// Regexp to match
this.matchRegExp = /\\(function|procedure|widget)\s+([^(\s]+)\((\s*([^)]*))?\)(\s*\r?\n)?/mg;
this.matchRegExp = /\\(function|procedure|widget)\s+([^(\s]+)\((\s*([^)]*(?:\)\)[^)]*)*))?\)(\s*\r?\n)?/mg;
};
/*

View File

@@ -0,0 +1,95 @@
/*\
title: $:/core/modules/parsers/wikiparser/rules/mvvdisplayinline.js
type: application/javascript
module-type: wikirule
Wiki rule for inline display of multi-valued variables and filter results.
Variable display: ((varname)) or ((varname||separator))
Filter display: (((filter))) or (((filter||separator)))
The default separator is ", " (comma space).
\*/
"use strict";
exports.name = "mvvdisplayinline";
exports.types = {inline: true};
exports.init = function(parser) {
this.parser = parser;
};
exports.findNextMatch = function(startPos) {
var source = this.parser.source;
var nextStart = startPos;
while((nextStart = source.indexOf("((",nextStart)) >= 0) {
if(source.charAt(nextStart + 2) === "(") {
// Filter mode: (((filter))) or (((filter||sep)))
var match = /^\(\(\(([\s\S]+?)\)\)\)/.exec(source.substring(nextStart));
if(match) {
// Check for separator: split on last || before )))
var inner = match[1];
var sepIndex = inner.lastIndexOf("||");
if(sepIndex >= 0) {
this.nextMatch = {
type: "filter",
filter: inner.substring(0,sepIndex),
separator: inner.substring(sepIndex + 2),
start: nextStart,
end: nextStart + match[0].length
};
} else {
this.nextMatch = {
type: "filter",
filter: inner,
separator: ", ",
start: nextStart,
end: nextStart + match[0].length
};
}
return nextStart;
}
} else {
// Variable mode: ((varname)) or ((varname||sep))
var match = /^\(\(([^()|]+?)(?:\|\|([^)]*))?\)\)/.exec(source.substring(nextStart));
if(match) {
this.nextMatch = {
type: "variable",
varName: match[1],
separator: match[2] !== undefined ? match[2] : ", ",
start: nextStart,
end: nextStart + match[0].length
};
return nextStart;
}
}
nextStart += 2;
}
return undefined;
};
/*
Parse the most recent match
*/
exports.parse = function() {
var match = this.nextMatch;
this.nextMatch = null;
this.parser.pos = match.end;
var filter, sep = match.separator;
if(match.type === "variable") {
filter = "[(" + match.varName + ")join[" + sep + "]]";
} else {
filter = match.filter + " +[join[" + sep + "]]";
}
return [{
type: "text",
attributes: {
text: {name: "text", type: "filtered", filter: filter}
},
orderedAttributes: [
{name: "text", type: "filtered", filter: filter}
]
}];
};

View File

@@ -61,7 +61,9 @@ ParametersWidget.prototype.execute = function() {
if(name.substr(0,2) === "$$") {
name = name.substr(1);
}
var value = pointer.getTransclusionParameter(name,index,self.getAttribute(attr.name,""));
var defaultValue = (self.multiValuedAttributes && self.multiValuedAttributes[attr.name])
|| self.getAttribute(attr.name,"");
var value = pointer.getTransclusionParameter(name,index,defaultValue);
self.setVariable(name,value);
});
// Assign any metaparameters
@@ -80,7 +82,8 @@ ParametersWidget.prototype.execute = function() {
if(name.substr(0,2) === "$$") {
name = name.substr(1);
}
var value = self.getAttribute(attr.name,"");
var value = (self.multiValuedAttributes && self.multiValuedAttributes[attr.name])
|| self.getAttribute(attr.name,"");
self.setVariable(name,value);
});
}

View File

@@ -158,8 +158,10 @@ Collect string parameters
TranscludeWidget.prototype.collectStringParameters = function() {
var self = this;
this.stringParametersByName = Object.create(null);
this.multiValuedParametersByName = Object.create(null);
if(!this.legacyMode) {
$tw.utils.each(this.attributes,function(value,name) {
var attrName = name; // Save original attribute name for MVV lookup
if(name.charAt(0) === "$") {
if(name.charAt(1) === "$") {
// Attributes starting $$ represent parameters starting with a single $
@@ -170,6 +172,9 @@ TranscludeWidget.prototype.collectStringParameters = function() {
}
}
self.stringParametersByName[name] = value;
if(self.multiValuedAttributes && self.multiValuedAttributes[attrName]) {
self.multiValuedParametersByName[name] = self.multiValuedAttributes[attrName];
}
});
}
};
@@ -313,7 +318,16 @@ TranscludeWidget.prototype.parseTransclusionTarget = function(parseAsInline) {
if(name.charAt(0) === "$") {
name = "$" + name;
}
$tw.utils.addAttributeToParseTreeNode(parser.tree[0],name,param["default"])
if(param.defaultType === "multivalue-variable") {
// Construct MVV attribute for the default
var mvvNode = {type: "transclude", isMVV: true, attributes: {}, orderedAttributes: []};
$tw.utils.addAttributeToParseTreeNode(mvvNode,"$variable",param.defaultVariable);
$tw.utils.addAttributeToParseTreeNode(parser.tree[0],{
name: name, type: "macro", isMVV: true, value: mvvNode
});
} else {
$tw.utils.addAttributeToParseTreeNode(parser.tree[0],name,param["default"]);
}
});
} else if(srcVariable && !srcVariable.isFunctionDefinition) {
// For macros and ordinary variables, wrap the parse tree in a vars widget assigning the parameters to variables named "__paramname__"
@@ -364,7 +378,11 @@ TranscludeWidget.prototype.getOrderedTransclusionParameters = function() {
// Collect the parameters
for(var name in this.stringParametersByName) {
var value = this.stringParametersByName[name];
result.push({name: name, value: value});
var param = {name: name, value: value};
if(this.multiValuedParametersByName[name]) {
param.multiValue = this.multiValuedParametersByName[name];
}
result.push(param);
}
// Sort numerical parameter names first
result.sort(function(a,b) {
@@ -394,10 +412,16 @@ Fetch the value of a parameter
*/
TranscludeWidget.prototype.getTransclusionParameter = function(name,index,defaultValue) {
if(name in this.stringParametersByName) {
if(this.multiValuedParametersByName[name]) {
return this.multiValuedParametersByName[name];
}
return this.stringParametersByName[name];
} else {
var name = "" + index;
if(name in this.stringParametersByName) {
if(this.multiValuedParametersByName[name]) {
return this.multiValuedParametersByName[name];
}
return this.stringParametersByName[name];
}
}

View File

@@ -381,19 +381,31 @@ filterFn: only include attributes where filterFn(name) returns true
Widget.prototype.computeAttributes = function(options) {
options = options || {};
var changedAttributes = {},
self = this;
self = this,
newMultiValuedAttributes = Object.create(null);
$tw.utils.each(this.parseTreeNode.attributes,function(attribute,name) {
if(options.filterFn) {
if(!options.filterFn(name)) {
return;
}
}
var value = self.computeAttribute(attribute);
if(self.attributes[name] !== value) {
var value = self.computeAttribute(attribute),
multiValue = null;
if($tw.utils.isArray(value)) {
multiValue = value;
newMultiValuedAttributes[name] = multiValue;
value = value[0] || "";
}
var changed = (self.attributes[name] !== value);
if(!changed && multiValue && self.multiValuedAttributes) {
changed = !$tw.utils.isArrayEqual(self.multiValuedAttributes[name] || [], multiValue);
}
if(changed) {
self.attributes[name] = value;
changedAttributes[name] = true;
}
});
this.multiValuedAttributes = newMultiValuedAttributes;
return changedAttributes;
};
@@ -431,7 +443,7 @@ Widget.prototype.computeAttribute = function(attribute,options) {
});
// Invoke the macro
var variableInfo = this.getVariableInfo(macroName,{params: params});
if(options.asList) {
if(options.asList || attribute.isMVV) {
value = variableInfo.resultList;
} else {
value = variableInfo.text;

View File

@@ -2,37 +2,42 @@ title: $:/core/ui/TiddlerInfo/Advanced/CascadeInfo
tags: $:/tags/TiddlerInfo/Advanced
\define lingo-base() $:/language/TiddlerInfo/Advanced/CascadeInfo/
<$let infoTiddler=<<currentTiddler>>>
''<<lingo Heading>>''
<<lingo Hint>>
<table class="tc-max-width">
<thead>
<$list filter="[[View]] [[Active Cascade Filter]] [[Template]]" variable="heading">
<th><<heading>></th>
</$list>
</thead>
<$list filter="[[$:/tags/ViewTemplate]tagging[]]" variable="ViewTemplate">
<tr>
<$let
view={{{ [<ViewTemplate>]+[split[/]last[]] }}}
tagFilter=`$:/tags/ViewTemplate${ [<view>titlecase[]] }$Filter`
activeCascadeFilterTiddler={{{ [all[shadows+tiddlers]tag<tagFilter>!is[draft]]:filter[<storyTiddler>subfilter{!!text}]+[first[]] }}}
activeCascadeFilter={{{ [<activeCascadeFilterTiddler>get[text]] }}}
activeTemplateTiddler={{{ [<currentTiddler>]:cascade[all[shadows+tiddlers]tag<tagFilter>!is[draft]get[text]] }}}
>
<%if [<activeCascadeFilterTiddler>!is[blank]]%>
<td>
<$link to=<<ViewTemplate>> ><<view>></$link>
</td>
<td>
<$link to=<<activeCascadeFilterTiddler>> />
</td>
<td style="text-align:center;">
<$link class="tc-btn-invisible" to=<<activeTemplateTiddler>>><$button class="tc-btn-invisible">{{$:/core/images/file}}</$button></$link>
</td>
<%endif%>
</$let>
</tr>
</$list>
<thead>
<$list filter="[[View]] [[ActiveCascadeFilter]] [[Template]]" variable="th">
<th><$transclude $variable="lingo" title=`Detail/$(th)$`/></th>
</$list>
</thead>
<$list filter="[[$:/tags/ViewTemplate]tagging[]]" variable="ViewTemplate">
<tr>
<$let
view={{{ [<ViewTemplate>]+[split[/]last[]] }}}
tagFilter=`$:/tags/ViewTemplate${ [<view>titlecase[]] }$Filter`
activeCascadeFilterTiddler={{{ [all[shadows+tiddlers]tag<tagFilter>!is[draft]]:filter[<storyTiddler>subfilter{!!text}]+[first[]] }}}
activeCascadeFilter={{{ [<activeCascadeFilterTiddler>get[text]] }}}
activeTemplateTiddler={{{ [<currentTiddler>]:cascade[all[shadows+tiddlers]tag<tagFilter>!is[draft]get[text]] }}}
>
<%if [<activeCascadeFilterTiddler>!is[blank]]%>
<td>
<$link to=<<ViewTemplate>> ><<view>></$link>
</td>
<td>
<$link to=<<activeCascadeFilterTiddler>> />
</td>
<td style="text-align:center;">
<$link class="tc-btn-invisible" to=<<activeTemplateTiddler>>>
<$button class="tc-btn-invisible">{{$:/core/images/file}}</$button>
</$link>
</td>
<%endif%>
</$let>
</tr>
</$list>
</table>

View File

@@ -0,0 +1,16 @@
title: MultiValuedVariables/AttributeFirstValue
description: ((var)) on non-MVV-aware widget attribute returns first value only
type: text/vnd.tiddlywiki-multiple
tags: [[$:/tags/wiki-test-spec]]
title: Output
\whitespace trim
<$let items={{{ [all[tiddlers]sort[]] }}}>
<$text text=((items))/>
</$let>
+
title: ExpectedResult
<p>$:/core</p>
+

View File

@@ -0,0 +1,19 @@
title: MultiValuedVariables/DefaultParameterMVV
description: Procedure default parameter value using ((var)) syntax to provide MVV default
type: text/vnd.tiddlywiki-multiple
tags: [[$:/tags/wiki-test-spec]]
title: Output
\whitespace trim
\procedure showItems(itemList:((defaults)))
<$text text={{{ [(itemList)join[-]] }}}/>
\end
<$let defaults={{{ [all[tiddlers]sort[]] }}}>
<<showItems>>
</$let>
+
title: ExpectedResult
<p>$:/core-ExpectedResult-Output</p>
+

View File

@@ -0,0 +1,16 @@
title: MultiValuedVariables/InlineDisplay
description: ((var)) in inline wikitext displays MVV with default comma-space separator
type: text/vnd.tiddlywiki-multiple
tags: [[$:/tags/wiki-test-spec]]
title: Output
\whitespace trim
<$let items={{{ [all[tiddlers]sort[]] }}}>
((items))
</$let>
+
title: ExpectedResult
<p>$:/core, ExpectedResult, Output</p>
+

View File

@@ -0,0 +1,16 @@
title: MultiValuedVariables/InlineDisplaySeparator
description: ((var||separator)) in inline wikitext displays MVV with custom separator
type: text/vnd.tiddlywiki-multiple
tags: [[$:/tags/wiki-test-spec]]
title: Output
\whitespace trim
<$let items={{{ [all[tiddlers]sort[]] }}}>
((items||:))
</$let>
+
title: ExpectedResult
<p>$:/core:ExpectedResult:Output</p>
+

View File

@@ -0,0 +1,14 @@
title: MultiValuedVariables/InlineFilterDisplay
description: (((filter))) in inline wikitext displays filter results with default comma-space separator
type: text/vnd.tiddlywiki-multiple
tags: [[$:/tags/wiki-test-spec]]
title: Output
\whitespace trim
((([all[tiddlers]sort[]])))
+
title: ExpectedResult
<p>$:/core, ExpectedResult, Output</p>
+

View File

@@ -0,0 +1,14 @@
title: MultiValuedVariables/InlineFilterDisplaySeparator
description: (((filter||separator))) in inline wikitext displays filter results with custom separator
type: text/vnd.tiddlywiki-multiple
tags: [[$:/tags/wiki-test-spec]]
title: Output
\whitespace trim
((([all[tiddlers]sort[]]||:)))
+
title: ExpectedResult
<p>$:/core:ExpectedResult:Output</p>
+

View File

@@ -0,0 +1,19 @@
title: MultiValuedVariables/TranscludeParameter
description: Multi-valued variable passed as procedure parameter via ((var)) syntax
type: text/vnd.tiddlywiki-multiple
tags: [[$:/tags/wiki-test-spec]]
title: Output
\whitespace trim
\procedure showItems(itemList)
<$text text={{{ [(itemList)join[-]] }}}/>
\end
<$let items={{{ [all[tiddlers]sort[]] }}}>
<$transclude $variable="showItems" itemList=((items))/>
</$let>
+
title: ExpectedResult
<p>$:/core-ExpectedResult-Output</p>
+

View File

@@ -0,0 +1,17 @@
title: MultiValuedVariables/TranscludeParameterFunction
description: Multi-valued variable passed as function parameter via ((var)) in $transclude
type: text/vnd.tiddlywiki-multiple
tags: [[$:/tags/wiki-test-spec]]
title: Output
\whitespace trim
\function showItems(itemList) [(itemList)sort[]join[-]]
<$let items={{{ [all[tiddlers]] }}}>
<$transclude $variable="showItems" itemList=((items))/>
</$let>
+
title: ExpectedResult
<p>$:/core-ExpectedResult-Output</p>
+

View File

@@ -22,6 +22,6 @@ There is also a single line form for shorter functions:
\function <function-name>(<param-name>[:<param-default-value>],<param-name>[:<param-default-value>]...) <single-line-definition-text>
```
The first line of the definition specifies the function name and any parameters. Each parameter has a name and, optionally, a default value that is used if no value is supplied on a particular call to the function. The lines that follow contain the text of the function (i.e. the snippet represented by the function name), until `\end` appears on a line by itself:
The first line of the definition specifies the function name and any parameters. Each parameter has a name and, optionally, a default value that is used if no value is supplied on a particular call to the function. <<.from-version "5.4.0">> The default value can also be a [[multi-valued variable reference|Multi-Valued Variables]] using the `((var))` syntax (e.g. `\function show(items:((defaults)))`). The lines that follow contain the text of the function (i.e. the snippet represented by the function name), until `\end` appears on a line by itself:
See [[Functions]] for more details.

View File

@@ -22,7 +22,7 @@ There is also a single line form for shorter procedures:
\procedure <procedure-name>(<param-name>[:<param-default-value>],<param-name>[:<param-default-value>]...) <single-line-definition-text>
```
The first line of the definition specifies the procedure name and any parameters. Each parameter has a name and, optionally, a default value that is used if no value is supplied on a particular call to the procedure. The lines that follow contain the text of the procedure text (i.e. the snippet represented by the procedure name), until `\end` appears on a line by itself:
The first line of the definition specifies the procedure name and any parameters. Each parameter has a name and, optionally, a default value that is used if no value is supplied on a particular call to the procedure. <<.from-version "5.4.0">> The default value can also be a [[multi-valued variable reference|Multi-Valued Variables]] using the `((var))` syntax (e.g. `\procedure show(items:((defaults)))`). The lines that follow contain the text of the procedure text (i.e. the snippet represented by the procedure name), until `\end` appears on a line by itself:
For example:

View File

@@ -4,7 +4,7 @@ release: 5.4.0
tags: $:/tags/ChangeNote
change-type: enhancement
change-category: hackability
github-links: https://github.com/TiddlyWiki/TiddlyWiki5/pull/8972 https://github.com/TiddlyWiki/TiddlyWiki5/pull/9614
github-links: https://github.com/TiddlyWiki/TiddlyWiki5/pull/8972 https://github.com/TiddlyWiki/TiddlyWiki5/pull/9614 https://github.com/TiddlyWiki/TiddlyWiki5/pull/9645
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.

View File

@@ -4,7 +4,8 @@ tags: $:/tags/ChangeNote
release: 5.4.0
change-type: enhancement
change-category: hackability
github-links: https://github.com/Jermolene/TiddlyWiki5/pull/9634
github-links: https://github.com/Jermolene/TiddlyWiki5/pull/9634 https://github.com/Jermolene/TiddlyWiki5/pull/9643
github-contributors: DesignThinkerer
The Tiddler Info panel's `Advanced` tab now displays the templates and filters used to render the current tiddler.
The Tiddler Info panel's `Advanced` tab now displays the templates and filters used to render the current tiddler.

View File

@@ -8,4 +8,6 @@ type: text/vnd.tiddlywiki
|!how declared|!behaviour|
|\define|Textual substitution of parameters is performed on the body text. No further processing takes place. The result after textual substitution is used as the attribute's value|
|<<.wlink SetWidget>>, <<.wlink LetWidget>>, <<.wlink VarsWidget>>, \procedure, \widget|Body text is retrieved as-is and used as the attribute's value.|
|\function|When a function (e.g. `.myfun`) is invoked as `<div class=<<.myfun>>/>`, it is a synonym for `<div class={{{[function[.myfun]]}}}/>`. As with any filtered transclusion (i.e. triple curly braces), all results except the first are discarded. That first result is used as the attribute's value. Note that functions are recursively processed even when invoked in this form. In other words a filter expression in a function can invoke another function and the processing will continue|
|\function|When a function (e.g. `.myfun`) is invoked as `<div class=<<.myfun>>/>`, it is a synonym for `<div class={{{[function[.myfun]]}}}/>`. As with any filtered transclusion (i.e. triple curly braces), all results except the first are discarded. That first result is used as the attribute's value. Note that functions are recursively processed even when invoked in this form. In other words a filter expression in a function can invoke another function and the processing will continue|
<<.from-version "5.4.0">> Using the [[multi-valued variable attribute|Multi-Valued Variable Attribute Values]] syntax `((var))` instead of `<<var>>` passes the complete list of values to the attribute rather than just the first value. This is primarily useful for passing [[multi-valued variables|Multi-Valued Variables]] to procedure and function parameters via the TranscludeWidget.

View File

@@ -59,14 +59,57 @@ For example:
```
\function myfunc(tiddlers) [(tiddlers)sort[]]
<$let varname={{{ [all[tiddlers]limit[50]] }}}>
<$let varname={{{ [all[tiddlers]limit[50]] }}}>
<$text text={{{ [function[myfunc],(varname)] +[join[-]] }}}/>
</$let>
```
! Examples
!! Passing Multi-Valued Variables to Procedures and Functions
For example:
<<.from-version "5.4.0">> Multi-valued variables can be passed to procedures and functions using the `((var))` syntax in [[widget attributes|Multi-Valued Variable Attribute Values]]. This is the multi-valued counterpart of the `<<var>>` syntax:
```
\procedure showItems(itemList)
<$text text={{{ [(itemList)join[-]] }}}/>
\end
<$let items={{{ [all[tiddlers]sort[]] }}}>
<$transclude $variable="showItems" itemList=((items))/>
</$let>
```
The `((var))` syntax can also be used in procedure and function parameter defaults:
```
\procedure showItems(itemList:((defaults)))
<$text text={{{ [(itemList)join[-]] }}}/>
\end
```
! Displaying Multi-Valued Variables
<<.from-version "5.4.0">> Multi-valued variables can be displayed inline in wikitext using the `((var))` syntax. The values are joined with a comma and space by default:
```
<$let items={{{ [all[tiddlers]sort[]] }}}>
((items))
</$let>
```
A custom separator can be specified using the `||` delimiter:
```
((items||:))
```
A similar syntax with triple round brackets is available for displaying the results of a filter expression:
```
((( [all[tiddlers]sort[]] )))
((( [all[tiddlers]sort[]] ||: )))
```
! Examples
```
<$let varname={{{ [all[tiddlers]sort[]] }}}>

View File

@@ -0,0 +1,37 @@
created: 20250208120000000
modified: 20250208120000000
tags: WikiText [[Widget Attributes]]
title: Multi-Valued Variable Attribute Values
type: text/vnd.tiddlywiki
<<.from-version "5.4.0">> Multi-valued variable attribute values are indicated with double round brackets around the variable name. This passes the complete list of values of a [[multi-valued variable|Multi-Valued Variables]] to the attribute, rather than just the first value.
```
<$transclude $variable="myproc" items=((myvar))/>
```
This is the multi-valued counterpart to the [[Variable Attribute Values]] syntax `<<var>>`, which only returns the first value for backwards compatibility. The relationship mirrors the existing convention in filter operands where `<var>` returns a single value and `(var)` returns all values.
! Non-MVV-Aware Attributes
When `((var))` is used on a widget attribute that does not support multi-valued variables (such as the `text` attribute of the TextWidget), only the first value is used:
```
<$text text=((myvar))/>
```
! Passing Multi-Valued Variables to Procedures
The primary use case for this syntax is passing multi-valued variables through the `$transclude` pipeline to procedures and functions:
```
\procedure showItems(itemList)
<$text text={{{ [(itemList)join[-]] }}}/>
\end
<$let items={{{ [all[tiddlers]sort[]] }}}>
<$transclude $variable="showItems" itemList=((items))/>
</$let>
```
In this example, the complete list of tiddler titles stored in `items` is passed to the `itemList` parameter of the `showItems` procedure.

View File

@@ -62,6 +62,28 @@ or, when used with a template, `{{{ [tag[mechanism]]||TemplateTitle }}}` expands
<<.tip "Install the //Internals// plugin to enable the display of the generated widget tree in the preview pane of the editor">>
!! Multi-Valued Variable Display
<<.from-version "5.4.0">> The `((var))` syntax can be used inline to display the values of a [[multi-valued variable|Multi-Valued Variables]], joined with a comma and space by default:
```
((myvar))
((myvar||:))
```
The optional `||` delimiter specifies a custom separator string.
!! Inline Filter Display
<<.from-version "5.4.0">> The `(((filter)))` syntax displays the results of a filter expression inline, joined with a comma and space by default:
```
((( [all[tiddlers]sort[]] )))
((( [all[tiddlers]sort[]] ||: )))
```
The optional `||` delimiter specifies a custom separator string. This is the inline display counterpart to the filtered transclusion `{{{ }}}` syntax.
---
See also:

View File

@@ -11,6 +11,7 @@ Attributes of [[HTML elements|HTML in WikiText]] and widgets can be specified in
* [[a transclusion of a macro/variable|Variable Attribute Values]]
* [[as the result of a filter expression|Filtered Attribute Values]]
* <<.from-version "5.3.0">> [[as the result of performing filter and variable substitutions on the given string|Substituted Attribute Values]]
* <<.from-version "5.4.0">> [[as a multi-valued variable reference|Multi-Valued Variable Attribute Values]]
|attribute type|syntax|h
|literal |single, double or triple quotes or no quotes for values without spaces |
@@ -18,9 +19,10 @@ Attributes of [[HTML elements|HTML in WikiText]] and widgets can be specified in
|variable |double angle brackets around a macro or variable invocation |
|filtered |triple curly braces around a filter expression|
|substituted|single or triple backticks around the text to be processed for substitutions|
|multi-valued variable |double round brackets around a variable name |
<$list filter="[[Literal Attribute Values]] [[Transcluded Attribute Values]] [[Variable Attribute Values]] [[Filtered Attribute Values]] [[Substituted Attribute Values]]">
<$list filter="[[Literal Attribute Values]] [[Transcluded Attribute Values]] [[Variable Attribute Values]] [[Filtered Attribute Values]] [[Substituted Attribute Values]] [[Multi-Valued Variable Attribute Values]]">
<$link><h1><$text text=<<currentTiddler>>/></h1></$link>
<$transclude mode="block"/>
</$list>