Is there a long form version of filtered transclusions?

The filtered transclusion is a very useful feature of tiddlywiki, we are familiar with the triple curly braces {{{ filter }}} and commonly made into plain text with <$text text={{{ filter }}}/>, however as an attribute only the first value is given.

I was wondering “If there is a long form version of filtered transclusions?” and if not what would it take to make one available?

  • For example add a $filter parameter to the Modern $transclude widget.
  • We could use the long form and use other parameters like the $output parameter.
  • We could also “not limit”, the output to the first only.
  • One example <$transclude $filter=" filter " $output="text/plain"/> with no need to use the text widget.
    • We can add +limit[1]] or first[] to the filter if one value is needed, even last[] if relevant.

Are you suggesting that

<$transclude $filter="..." $output="text/plain"/>

would be a shorthand equivalent for

<$list filter="..."><$transclude $output="text/plain"/></$list>

Yes, but to put it a little simpler

<$transclude $filter="..."/>

would be the long hand for

{{{ filter }}}

But also allow other transclude parameters to be used. In one example also using the $output parameter. However there may not be many relevant parameters.

Perhaps we can even allow

<$transclude $tiddler="tiddlername" $filter="..."/>

Which may transcude tiddlername like;

{{{ filter || tiddlername }}}

In normal wikitext {{{a b c}}} is shorthand for <$list filter="a b c"/>

In widget attributes:

<$text text={{{ a b c }}}/>

is short for

<$list filter=" a b c :and[first[]]"><$text text=<<currentTiddler>>/></$list>
1 Like

In particular I was hoping for a long form in the transclude widget to use templates etc… But it seems there is no existing long form of filtered transclusions.

  • I may just build the features I want into a transcludable tiddler making use of they new features.

That’s a shorthand for a list-widget with a template parameter. You can see that in the Parse-Tree preview pane- There is no need to include code into the transclude widget, that is already part of the list-widget.

1 Like

The final widget-tree looks like this. A combination of the list widget. list-items and the transclusion of the template

So it is fair to say that the long form of “filtered transclusions” is a list widget?

I will have to concider this again and see if there are gaps, even the methods I may use and the new transclusion, features to understand this, but thanks for the answer @pmario and the method you used.

  • The template parameter on the list widget is a form of transclusion, so a deeper look at the posibilities is warented.

Yes. That’s right. There have been some discussions at GitHub if that was the best decision to be made. Especially since the default template of the list-items are links and not plain text. But it was a convenient shortcut as it was invented.

That’s one reason, why the new \function definition exists.

Assigning a filtered transclusion to a variable technically is a bit hacky. But in the early days there has been no other way to resolve a filter and assign it to a variable.

Here’s the parse-tree of a function.

Yes, I am experimenting with the list widget, and a template, or transclude widget to create the equivalent, in which I may be able to use some of the new form of transclued;

<$let test=got-ya>
<$list filter="[tag[TableOfContents]]" template=listitem/>
</$let>

<$let test=got-ya>
<$list filter="[tag[HelloThere]]">
<$transclude tiddler=listitem>
</$list>
</$let>
  • Perhaps later I will make a procedure or even widget.

Notes;
The parameter widget and pragma work generaly so they do work in a transcluded list item.

We could – But that would be a compatibility problem. Every bit of code, that assumes otherwise would need to be changed.

There is only 1 widget, that can deal with an “array” of elements as a filter output. That’s the list-widget.

So it does not really make sense to allow an assignment of “arrays” to other widgets. They cannot handle them directly as an array. If several HTML elements have to be created, there has to be a list-widget somewhere.

In the OP you wrote we could use the first[] operator like: <$text text={{{ [tag[HelloThere]first[]] }}}/> if we would want to limit a list to 1 element as an output. – That’s right.

The same is true If I say:
We can use <$text text=`${ [tag[HelloThere]format:titlelist[]join[ ]] }$`/> to show the whole list. It’s absolutely the same argument. – Just the other way around.

We could argument that the later construction is more complex.

I’d say: Not if we use <$set name=myList filter="[tag[HelloThere]]">, which is the generic way to assign “arrays” to a variable.

So using the set-widget with a filter, we can do both:

Define a myList variable
<$set name=myList filter="[tag[HelloThere]]">
and oneTitle
<$set name=oneTitle filter="[tag[HelloThere]first[]]">

If you have a closer look at the screenshots, you’ll also see, that the \function pragma internally is translated to a set-widget with a isFunctionDefinition: true in the parse-tree.

That’s also true for \define and \procedure. Internally they are variables with a isX marker

Hope that makes sense
-m

Thanks @pmario that restates things nicely. If a widget does not know how to handle a list I am fine with that, but what If I wanted to pass a list to a custom widget or html designed to handle a list;

<$mywidget list=`$( [tag[HelloThere]] )$`/>
  • I cant because only the fist item will be given
  • Now imagin I was granted another form say ($ filter $) that did not do this, but set the attribute to the whole list
<$mywidget list=`($ [tag[HelloThere]] $)`/>
  • Then without any fuss I could set an attribute to a list of values, whenever I wanted without any of these confusing work arounds.
  • It breaks no rules, at worst it allows you to give lists to parameters that dont handle it as a list, just as a string. I would no longer beforced to accept first only on attribute values.
  • What if my list was a valid multivalue string list float: right; width:50% generated by a filter ?

Similarly I have to use the <$text text="code"/> quite a lot so it would be nice if we had a shorthand, perhaps wikitext, for this too. Which is why I was asking in the OT for the long form of the transclude, to see if I could just make the output plain text.

  • I suspect slot/fill may provide one method with transclusions, but again its much more long winded that having a mechanisium that does not force the “first only”.

Use <$set name=myList filter="[tag[HelloThere]]"> or any other possibility we did discuss at Thanks for the silent help! - #27 by pmario

The enlist and enlist-input operators can split them into arrays again, that can be used by the list-widget, which can be part of your own widget if you need it that way.

If you need to deal with parameter names and parameter values that you do not know upfront, you’ll need to deal with the $names and $values parameters from the genesis-widget … They also need title-list like values