When trying to create a certain zig-zag look1, I managed it with this pattern:
<table class="signs">
<$list filter="[tag[Sign]]" counter="counter">
<tr>
<$list filter="[<counter>remainder[2]match[1]]" variable="_"><<sign-link>></$list>
<!-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -->
<td class="meta"><!-- ... more here ... --></td>
<$list filter="[<counter>remainder[2]!match[1]]" variable="_"><<sign-link>></$list>
<!-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -->
</tr>
</$list>
</table>
This simply adds certain content as either the first or second cell in a table, and the other content as the second or the first. (Perhaps that would be better as match[0]
instead of !match[1]
.)
Those highlighted sections are certainly not horrible. But it made me want to have counter-even
and counter-odd
similar to counter-first
and counter-last
. I could also see something similar to CSSâs nth-child
, with something like counter-nth(5n+1)
That would turn the above into:
<$list filter="[<counter-odd>]" variable="_"><<sign-link>></$list>
<!-- ^^^^^^^^^^^^^^^ -->
<td class="meta"><!-- ... more here ... --></td>
<$list filter="[<counter-even>]" variable="_"><<sign-link>></$list>
<!-- ^^^^^^^^^^^^^^^^ -->
My question is whether others would find this useful? Although I have one minor contribution to TW, this would be the first substantive one I might create. I wonât bother bringing it up in GitHub if Iâm the only one who sees it as useful. As I said, the above isnât bad, but this would feel cleaner. Have I missed a built-in version of this?
I recognize that the counter
can be a drag on performance, but "The best advice is only to use it when it is really necessary: to obtain a numeric index, or to detect the first or last entries in the list." (frrom #ListWidget). And this would seem to be an obvious extension to it.
So, is this something you would use?
1What Iâm going for is the following zig-zag pattern:
You can see the fairly minimal code that achieved it by dragging zigazg.json (1.7 MB) to an empty wiki, and loading the tiddler Sign
. (The CSS is in styles/main
, and it involves what is probably an abuse of direction: rtl;
; Iâll clean that up later.)