The $parameters widget now allows a variable to be named and set containing all parameter/value pairs either named or unnamed
...
$params="params-var"
...
Optional name of a variable in which is made available the JSON representation of the parameters passed to the parent transclusion (as an object where the keys are the parameter names and the values are the corresponding values)
I would hope we can put together a little more documentation to help make use of such a string and link to it from the $parameters widget documentation.
For example how could w eremove the first parameter and pass on the rest to another variable
How do we feed this into a setMultipleVariables or setMultipleFields action
But also;
Would it be possible to add to the $transclude widget an additional parameter eg $params so that a variable set to the above could be use to pass all the above parameters to the procedure we are calling eg;
This will help with procedures and widgets that themself call other procedures by permitting all the parameters to be passed through to the called procedure.
Such a $params may replace all parameters passed
Even better if it could be combined with other-param but less important
It would be useful if we could do this for widgets as well.
In this example we use the proposed $params parameter to pass in the JSON string of parameter value pairs.
These would then be applied to the transclusion of sub-proc as if they were separate param=value items in the transclusion (of sub-proc)
That is given we can capture all parameters named or otherwise using the parameters widget provide a means to pass one or more on to the next procedure/widget.
Adjust [<params-var>jsonindexes[]] to filter the parameters however you like.
The $names/$values attributes of $setmultiplevariables and $fields/$values attributes of $action-setmultiplefields should have the same behavior of the corresponding attributes in the $genesis widget.
Now imagin the code you provided replaced by a parameter on the transclude widget $input-params=<<varname>> where varname was set using the $params attribute of the $parameters widget.
passing all indeterminant parameter names and values from one process/widget to another.
How?
giving the transclude widget the ability to accept a parameter which replaces or is appended to the calling parameters
accepting the json form of the parameters
Why
simplify widgets and procedures calling widgets and procedures.
allow indefinite numbers and names of parameters to be passed on
write widgets and procedures that intercept core widgets and procedures and then invoke the original with all parameters without knowledge of all parameters.
create code that handles and formats parameters into sets of key/value pairs for storage and execution
A key value of this idea would be the ease by which one could store a complex set of parameter/value pairs in the JSON format and apply them later. For example;
filters and values to create new tiddlers
alternative parameter sets you can select from
multiple code examples whose only difference is the parameters
given a filter is a valid parameter value it can be evaluated at render time.
For example it would be possible to store parameter sets in a single value or field capable of conditionaly setting or clearing multiple tags fields and even variables.
we could even construct logical tiddlers we call parameter sets, that can be applied to any tiddler(s)
this would help on documentation, interactive examples and tools to write tiddlywiki script.
I think there is a fair argument that unless this is simplified to a special parameter the current way to achive this, illustrated by @btheado, would be too much of a cognative load to be made use of regularly.
You could implement a my-transclude procedure which does this simplification (internally making use of the genesis widget). Then you could illustrate its usefulness with concrete example calls and resulting rendered output.
Thank you both for giving examples and insights.
For me, mastering the new features in TW 5.3.1 takes more time comparing to 5.1.x
But these kind of examples are very helpful to shorten my learning curve.
I know you are looking for an easier implementation, but IMO implementing it the “hard way” first can be illustrative.
Note in the transclude genesis call I’m using = to prevent de-duplication. It is important the $names and $values match in order and length. De-duplication would mess that up.
Thanks @btheado I did read your guidence to explore the genesis widget first, my need to study it delayed me somewhat. But your worked examples are great.
Functions do help make things much more readable. I will focus on this in more detail today.
I have taken this further today and dump an example of my experiments without a complete explanation for people interested in studying the possibilities.
In the below I take the “functionalisation” - “creation of functions” further
I abandon the genesis widget by adoption of params variable as a defacto standard variable in which to store parameters.
Place this in tiddlywiki.com and read through the code to see the methods I am testing.
On further reflection with my original desire for the above, and community input especialy @btheado, I can confidently say that with an effective code pattern and some defacto standard variable names, this is not nessasary and in fact would be more limited than what we can already achive.
I would mark this thread as solved if I could.
Hopefully I will get to share these methods with the community in some powerful examples in the fullness of time.
For Example;
I can now see how I can capture and extract multiple parameters in a JSON string.
This set of parameters can be stored in a tiddler/field/variable and reapplied later as needed.
This satisfies my long desired ability to set, share, store and access multiple key/value pairs.
What is the next big thing I can do with these code patterns?
Capture key/values pairs of the form fieldname/subfilter where subfilter is that used in the listops widget with its rich set of Extended Listops Filters
These parameter sets can then can be processed and applied to the current tiddler and contain a great deal of logic handling single value and list fields.
The filters can also be generalised via functions
Yet another big step forward in what I/we can do with TiddlyWiki script
I’m not sure what you mean here, but one possibly related thing I noticed is the $params parameter of the parameters widget only includes the the parameters which are explicitly passed in. If you want to make use of default values (i.e. filter="[all[current]]" below) then you would need to explicitly add each one to the filter:
Ha ha. Those notes in my post before last were to myself and slipped in by mistake. I will review the issue you raised about the $parameters own parameters.
By instantiate I think I was asking how to take a set of parameters and values and store them as the JSON object to store for later use and they easiest way is the parameters widget. But I want to know how to do it without the $Params widget.
Thanks to you @btheado I see two areas of complementary research.
Your examples are about going via the genesis widget to existing widgets without modifying the target widget. This importiant to extend or leverage existing widgets.
My focus at present is passing all parameters from one procedure or widget to another procedure or widget without nessasarily knowing anything about those parameters. Typicaly where all coding is mine.
The key observation here is the $params variable set in one procedure or widget is available in ones you call as long as you dont reset the variable.
So a set of parameters is available in the variable and can be decomposed using setmultiplevariables or the genesis widget at the point the original parameters are needed.
What is clear to me is the OT need not involve core changes and it is sufficent to develop appropriate code patterns based on the JSON parameters objects.
Postscript
Above I mention using the parameters widget in widgets and procedures but I think we can also use it in transclusions.