Filter expression for tiddlers whose wikitext evaluates to something non-empty?

I’m trying to create a template for a table that transcludes the content of each tagged “$:/tags/TableRow” as a new row. Here is what it looks like:

<table>
<$list filter="[tag[$:/tags/TableRow]]" variable="listItem" >
    <tr>
        <td>
            <$transclude $tiddler=<<listItem>>/>
        </td>
    </tr>
</$list>
</table>

I want to use this in a similar way to the ViewTemplate, where the TableRow tiddlers could themselves contain a list widget that is used to display them conditionally.

For example a TableRow tiddler might contain:

<$list filter="[all[current]prefix[Example:]]">
A table row to appear only on tiddlers prefixed "Example:".
</$list>

The problem is that even if the table is transcluded on a tiddler that does not match the condition [all[current]prefix[Example:]], a blank row gets created. I’ve tried using a filter like [tag[$:/tags/TableRow]] :filter[get[text]!is[blank]] but this doesn’t work, because even though it might evaluate to nothing, the TableRow tiddler still has text in it.

I’m struggling to think of a pattern that will transclude a new row only if the content of the TableRow tiddler actually evaluates to something. Can anyone help?

This is because

<$list filter="[tag[$:/tags/TableRow]]" variable="listItem" >
    <tr>
        <td>

Will generate tr and td elements regardless of the content of the tiddler tagged with $:/tags/TableRow

To avoid empty row, you need to put your filter before :

<$list filter="[tag[$:/tags/TableRow]] :filter[..]" variable="listItem" >
    <tr>
        <td>

or using a second list widget:

<$list filter="[tag[$:/tags/TableRow]]" variable="listItem" >
<$list filter="[..]" >
    <tr>
        <td>

Thanks @telumire. Is [..] some special syntax or are you using it as a placeholder for an unspecified filter run?

I actually just came up with an (ugly) solution that seems to work:

<table>
<tr><th>Header</th></tr>
<$list filter="[tag[$:/tags/TableRow]]" variable="listItem" >
<$wikify name="wikifiedListItem" text={{{ [<listItem>get[text]] }}}>
<$list filter="[<wikifiedListItem>!is[blank]]" variable=_ >
    <tr>
        <td>
            <$transclude $tiddler=<<listItem>>/>
        </td>
    </tr>
</$list>
</$wikify>
</$list>
</table>

There is something that I don’t understand though. If I place the value of the text parameter in quotes (i.e. text="{{{ [<listItem>get[text]] }}}"), it seems that <<wikifiedListItem>> is no longer seen as blank by TiddlyWiki. I don’t understand this because I thought that the wikify widget would just keep wikifying the text parameter until there is no wikitext left. If anyone could explain it would be much appreciated :slight_smile:

No. It’s a bit unlucky formulation. The 2 dots are meant as a placeholder for your filter expression.

Try this:

<$list filter="[tag[$:/tags/TableRow]] :filter[get[text]!is[blank]]" variable="listItem" >
    <tr>
        <td>

It takes the currentTiddler title, reads the text and checks if it is not empty. So every tiddler which has the tag but no text area will not be shown.

Basically the same thing you do, but without the wikify-widget

It’s important, that the text content of the tiddler is completely empty. Even if there is a space, or a carrage-return in the text area it will be “not blank”.


You should try to avoid the wikify widget in lists. It can slow down your wiki.

Thanks @pmario, but that is exactly what I already tried!

The problem is that some of my tiddlers tagged “$:/tags/TableRow” will contains a list widget condition that tell it not to display in certain contexts (i.e. the same pattern commonly used with “$:/tags/ViewTemplate”), but of course they still contain wikitext so [get[text]!is[blank]] will still return a result. This is why I ended up using the wikify widget, but I’m very open to alternative suggestions! :slight_smile:

@Sii consider transcluding content because when you do so it gets wifified. If its filter content that needs to be included in another filter from 5.3.0 use a filter defined with a function.

  • I am happy to expand on this if asked.

Maybe I’m not understanding the situation, but why not put the <tr><td></td></tr> in the TableRow tiddler so that those html tags never get displayed unless the condition is met in the TableRow

If I am misunderstanding, then perhaps you should use a reveal to determin when to dispay the <tr><td>