Using $genesis for conditional <ul> and <ol>

Here’s another use for my favorite new widget from the 5.2.5 release, $genesis, that will make your source code look better (subjectively):

Imagine you want to display the results of a filter in an <ul>, so you might do something like

<$list filter="[<filter-sequence>first[]]" variable="void">
	<ul>
		<$list filter="[<filter-sequence>]">
			<li>
				<<currentTiddler>>
			</li>
		</$list>
	</ul>
</$list>

There are probably other ways to do this, but let’s assume that’s what you’d do.
Note that <filter-sequence> is a placeholder for a sequence of filter steps.
Now if <filter-sequence> is rather computation-intensive (like full-text searches and such in a large wiki), you’d compute it only once and save the results in a variable like this

<$set name="results" filter="[<filter-sequence>]">
	<$list filter="[<results>!is[blank]]" variable="void">
		<ul>
			<$list filter="[enlist<results>]">
				<li>
					<<currentTiddler>>
				</li>
			</$list>
		</ul>
	</$list>
</$set>

Now, with $genesis, this can be made prettier:

<$set name="results" filter="[<filter-sequence>]">
	<$genesis $type={{{ [<results>!is[blank]then[ul]] }}}>
		<$list filter="[enlist<results>]">
			<li>
				<<currentTiddler>>
			</li>
		</$list>
	</$genesis>
</$set>

I don’t think it will be faster, as the filter expressions are the same, but it avoids the nested $lists which personally I always find a bit cluttered.
Note that this only works with the TW ≥ 5.2.6-prerelease fixed version of $genesis.

PS: This also works with <table> instead of <ul> and <tr> instead of <li>.

I think it should be like this: See the subfilter otherwise your some-filter-expression is no real filter-expression. It’s text snippet.

\define some-filter-expression() [tag[HelloTherex]]

<$set name="results" filter="[subfilter<some-filter-expression>]">
	<$genesis $type={{{ [<results>!is[blank]then[ul]] }}}>
		<$list filter="[enlist<results>]">
			<li>
				<<currentTiddler>>
			</li>
		</$list>
	</$genesis>
</$set>

IMO examples posted should work if users copy paste them. … We do have the same problem with many elements of the TW docs.

I changed the OP to make it explicitly clear that <filter-sequence> is just a sequence of filter steps. I did not want to make the example more complicated by using the subfilter operator.