Hello,

I have solved a problem that I had. But it seems to be to be an inelegant 
solution where maybe I am missing something.

I wanted to take a field from a tiddler and use it as a part of a filter 
expression within the same tiddler. I tried a ton of different method to 
find a solution but it seemed that no matter what I tried (quotes, no 
quotes, <$set>$(variables)$, <<macros>>, <$transculsions>, 
{{!!transclusions}}, etc.), it all seemed to break the parsing of the 
filter expression (resulting in a table of gibberish) or didn't match the 
expression I wanted since it didn't evaluate the variable (leading to a 
table of nothing).

So in the end, I took the brute force method of building up a filter 
expression using a custom concatenation macro of a boiler-plate filter 
prefix, the field that I wanted to slip in and a boiler-plate filter 
suffix. The resulting simplified, generalized code is:

\define filtertransclude(t1,t2,t3)
$t1$$t2$$t3$
\end

<table>
<tr>
<th>Table Header</th>
</tr>
<$set name="field_variable" value={{!!field_of_interest}}>
<$list filter=<<filtertransclude "[!has[draft.of]tag[tag_of_interest]field:
field_of_interest[" "$(field_variable)$" "]sort[]]">>>
<tr><td><$link to={{!!title}}><$view field="name"/></$link></td></tr>
</$list>
</$set>
</table>


This builds a table in a tiddler (assuming there are matching tiddlers with 
the tag "tag_of_interest" and the field "field_of_interest" containing the 
same value as that in the current tiddler) using a filter controlled by a 
field value in the tiddler rather than having to hand-edit the filter 
expression.

My reasoning for posting this is two-fold. To help anyone who has come 
across this issue. Also, to see if I am missing something fundamental about 
using variables and macros in filter expressions from those who are 
TiddlyWiki gurus. I learn a lot every time I post a solution to someone's 
problem so I hope that I can do so again by posing the solution to my own :]

/Mike

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/tiddlywiki.
For more options, visit https://groups.google.com/d/optout.

Reply via email to