Name of a variable passed in a transclusion parameter?

Is there a way to get the name of the transclusion used in a parameter?

My way around this at the moment, is to pass the name of a variable rather than the transcluded variable itself. Then, using a local proc, I create the intended transclusion via <$tranclude>. But is there a better way?

In the following, I’m passing the value "some-proc" into the parameter change-handler, notably not <<some-proc>> (because I want to print its name in the klass string). When it’s passed as a string like that, I then need to execute "some-proc" in the procedure handler.

\widget $edit-text.buffered(selector, change-handler, tag, class)
\procedure handler()
  <$transclude $variable=<<change-handler>> />
\end handler
<$let klass={{{ [[E:CHANGE widget:$edit-text.buffered selector:$(selector)$ $change:$(change-handler)$ $(class)$]substitute[]] }}}>
<$eventcatcher selector=<<selector>> $change=<<handler>> tag=<<tag>> class=<<klass>>>
  <$slot $name="ts-raw"/>
</$eventcatcher>
</$let>
\end $edit-text.buffered

If there was some way to extract “some-proc” from <<some-proc>> I wouldn’t need the procedure and the “extra” <$transclude>. My suspicion is, there’s nothing in wikitext that would allow me to “look back up the tree”.

Thanks for reading.

1 Like

For reference, this thing is an evolution of this stuff – updated to use widgets and other 5.3 goodness. :yum:

I asked myself a similar question recently and went looking for an answer, I got some hints that it may be possible but there are half a dozen ways to code arround it.

My answer is to reverse your question.

  • by passing the variable/procedures “name” in a variable, as you have, you have the name available and you can use this within the Getvariable operator to obtain the value of that variable.
  • using this approach makes it easier to pass parameters as simple text then use it to call macros, procedures, use functions and transclude, and also set a default value.

Speculation
Perhaps we could even do this inside the parameters widget?

1 Like