Closed Wattaged closed 4 years ago
Hmm, yeah. Assembling strings for attributes has always been a hassle in tiddlywiki. Your query macro doesn't get a chance to render the transclude widget before it gets put in. So xpath is getting passed /dog[age=<$transclude tiddler="test"/>]/breed
. (The error is showing the wikiRendered version of that, which is misleading, and something I need to fix.)
To get the results you want, try this:
\define query()/dog[age=$(num)$]/breed
<$vars num={{$:/temptest}}>
<$select tiddler='$:/temptest'>
<option value='3'>3</option>
<option value='4'>4</option>
<option value='7'>7</option>
</$select>
{{{ [xpath<query>] }}}
</$vars>
I'll leave this issue open, because I need to fix the xpath error message so it isn't misleading like that.
Thanks very much. It works! The interaction between the TW and xpath methods is a mind bender so really appreciate the help. More of these practical examples on the web page would definitely get my vote. Thanks again.
The "Invalid Query" error message is improved, and an example on creating dynamic queries has been added to the demo site.
Closing issue.
Thanks for this flibbles. Is it possible to transclude values into xpath queries? I've tried several ways but no luck. A select seems to transclude the value in but it still doesn't like it.