How to get the specific value of a variable after the variable filter has been passed in

I want to get the value of the passed filter, in the first code below I set a chapterText variable which is then combined into littleFilter, but I don’t get the value I want in the second code. It only outputs [chpater<chpaterText>], which I’m using in a different template, so theoretically <<littleFilter>> should show up as a specific value, like [chapter[01]]. Strangely, if I display the value of chapterText directly in the procedure, it is able to display it normally, <<chapterText>> output: 01. So how do I pass in the display this filter variable?

<$let
stateFilterName={{{ [[$:/state/cluster/chapter/filter/]addsuffix{!!title}] }}}
stateID={{{ [[$:/state/cluster/chapter/]addsuffix{!!title}] }}} 
popupstate=<<qualify "$:/state/cluster/chapter/display">> 
chapterText={{{ [<currentTiddler>get[chapter]] }}} 
stateIDText={{{ [<stateID>get[text]else[-copy]] }}} 
rootTag={{{ [<currentTiddler>tags[]tags[]] }}} 
captionText={{{ [<currentTiddler>has[caption]get[caption]] }}} >

<$transclude $tiddler="cluster-chapter-button"/>

<$tiddler tiddler=<<currentTiddler>> >
	<$transclude $variable="cluster-chapter-procedure" realSuffix=<<stateIDText>>  littleFilter="[chapter<chapterText>]" stateFilterName=<<stateFilterName>> rootTag=<<rootTag>> captionText=<<captionText>>/>
</$tiddler>

</$let>
\procedure cluster-chapter-procedure(realSuffix,littleFilter,stateFilterName,rootTag,captionText)
<$let
stateFilterName=<<stateFilterName>>
stateFilter={{{ [<stateFilterName>get[text]] }}}
rootTag=<<rootTag>>
copyTag={{{ [<rootTag>addsuffix<realSuffix>] }}}
filter="[tag<copyTag>filter<littleFilter>] +[search:title<stateFilter>]"
filterCount={{{ [tag<copyTag>filter<littleFilter>] +[search:title<stateFilter>] +[count[]] }}} >
<%if [<filterCount>match[0]] %>
<%if [<stateFilter>is[blank]] %>
<<chapterText>>
<<littleFilter>>
<h2>筛选器 <$text text=`[tag[$(copyTag)$]] +${[<littleFilter>]}$`/>  无内容</h2>
<%else%>
<$button class="grey-dark">
<$action-setfield $tiddler=<<stateFilterName>> text="" />
输入文本错误,请重置搜索框
</$button>
<%endif%>
<%else%>
<$transclude $tiddler="cluster-chapter-display-template" realFilter=<<filter>> captionText=<<captionText>>/>
<%endif%>
</$let>
\end

If you are trying to get the exact text in this format “[chapter[01]]” rather than actually running the filter at that moment, I believe it must be like this:

<$tiddler tiddler=<<currentTiddler>> >
	<$transclude $variable="cluster-chapter-procedure" realSuffix=<<stateIDText>>  littleFilter=`[chapter[$(chapterText)$]]`> stateFilterName=<<stateFilterName>> rootTag=<<rootTag>> captionText=<<captionText>>/>
</$tiddler>

This uses back ticks (`) around the value, and the $(chapterText)$ format for inserting the variable

This will make littleFilter be the exact text “[chapter[01]]”, the 01 depending on the value of chapterText

Or maybe I am mistaken about what end value you are looking for.

2 Likes

I am needing to show the specific value of littleFilter in the procedure. Here I am just using [chapter<chpaterText>] one case, and in my actual use I might also pass a more complex filter expression. But I don’t know how to display it.

In other words, if the variable filter for littleFilter that I set in transclude is [chapter<chpaterText>] , and the actual specific value is [chapter[01]], I would like to be able to show that specific value in the procedure as well to clue me in to the fact that the content does not exist in the current filter. If I set [chapter<chapterName>section<sectionName>] in transclude, then the value actually passed in is [chapter[01]section[01]], so I want to be able to get that specific value in the procedure as well. But I don’t know how to handle it.

Holy shit, it came true, I didn’t think it would come true, but with the idea of giving it a try, it did. That’s awesome. Mind you I tried for over two hours in the morning and couldn’t figure out how to handle it. Thank you so much, I didn’t think this would work.

1 Like