A question about transcluding into the vars widget

Folks,

Another long standing question of mine, I have finally found out how to ask.

When you use set or vars widgets they need to be closed or closure is assumed at the end of the tiddler in some circumstances. This means the need to wrap around the area where they are valid.

The advantage of the vars widget is you can have one or more variables set and close the widget once (always) rather than the set widget(s) which requires multiple closing </$set> statements.

For example;

<$vars
  variable1={{!!field1))
  variable2={{tiddlername}}
>

Some wikitext that uses the variables

</$vars>
  • My Question is; Is there any way to replace the following part of the vars widget;
  variable1={{!!field1))
  variable2={{tiddlername}}

with a “transclusion or variable” that can name the variable(s) and there values?, such that I can change the number of variables defined by changing the contents of the “transclusion or variable”?

The reason I ask is: This would be a way to introduce some hackability to “programaticaly introduce new variables” without editing the tiddler that contains the var widget, and allow Some wikitext that uses the variables to respond to changes in those variables?

I hope others can learn from my resolution of this issue.

  • I must also say as far as I can see the answer is no, but it seems to me a missing feature in how we can code wikitext, macros and variables. I have seen and identified a number of cases where I come up hard against this “apparent” limitation.
  • Thus if no what can we do about it?

Once again, thanks in advance.

1 Like

Hi @TW_Tones. Interesting question – funnily enough, in my current work on TWPub I have encountered what I think may be the same need. I ended up implementing a new widget:

<$setmultiplevariables $names=<<name-filter>> $values=<<value-filter>>>
...
</$setmultiplevariables>

The $names attribute is a filter that yields the names of the variables to be set, and the $values attribute is a filter that yields the corresponding values of the variables to be set.

An example usage from my work is:

<$setmultiplevariables
	$names="[<currentTiddler>fields[]removeprefix[var-]]"
	$values="[<currentTiddler>fields[]prefix[var-]getfield<currentTiddler>]"
>
	<$tiddler tiddler=<<storyTiddler>>>
		<$transclude tiddler=<<templateTiddler>>/>
	</$tiddler>
</$setmultiplevariables>

The getfield operator is also new; it interprets the input list as field names and the operand as the tiddler title from which to retrieve them. There is also a companion <$action-setmultiplefields> widget too.

You can see these widgets in GitHub:

The exploration that prompted the creation widgets is an attempt to implement the <$navigator> widget in wikitext, as has been discussed here:

We’re using TWPub as a testbed for a number of ideas that have been under discussion for a while: particularly multicolumn layouts, and multiple story rivers.

3 Likes

GOLD.

And great question @TW_Tones – I’ve wanted this capability for so long and convinced myself (mostly) it’s just not possible (I think I posted something stupid about it on Github discussions).

Wow. That sounds perfect or even better.

Actualy i can see your interest is in the same area. I think i can propose extra hackability to the viewtemplates to eliminate some of the few fundimental barriers.

However your duel filter approach could provide some opportunities for some unique innovations.

I have to think about that.

Indeedy. My brain is… :exploding_head:

I need to go lie down for a while :laughing:

1 Like

@jeremyruston Are these widgets prime-time ready?

If not prime time could we please have access via a POC plugin so we need not wait for 5.2.1? @jeremyruston

I ask in part because in a future release these widgets could be used in viewtemplate and other places for new features and hackability.

1 Like

The more I think about this the more exciting I think it is. I mean… 5.2.0 is a completely astounding release with so much new stuff and improvements it boggles the mind. Then THIS.

It’s testament to the TiddlyWiki core – strength in depth

Truly a tinkerer’s paradise.

Same here @CodaCoder off line i have a whole suit of ideas from this. I expect i should wait until this “flight of fancy” mood ends to avoid verbose replies. Once again the possibilities are endless.

One key area is array manipulation, another is encode decode and yet another is data tiddler manipulation.

Thanks @CodaCoder @TW_Tones, and thanks for your patience.

I’ve made a PR for the changes discussed here: