On Thursday, February 6, 2020 at 9:17:07 AM UTC+1, Mohammad wrote:
>
> from https://tiddlywiki.com/prerelease/#qualify%20Macro
>
> The qualify macro is an important part of the StateMechanism.
>

Not really. The state mechanism works perfectly fine, without the qualify 
macro. The <<qualify>> macro solves a very special usecase. It was built to 
create unique names for templates used in the core UI.
 

> It returns a unique string that encodes its position within the widget 
> tree, as identified by the stack of transcluded tiddlers that lead to that 
> position.
>

That's right. This behaviour is intended. AND it means: "As soon as the 
<<qualify xxx>> code is *transcluded*, it will create a *_different_ string*
!"
That's the only thing your examples show and that's intended.
 

> ISSUES
> It is true that qualify should returns a unique, but considering 
> transclusion in Tiddlywiki it cause confusion!
>

I think it doesn't do what you expect and that produces confusion. You 
can't use qualify in your examples as you do, because of the nature of 
qualify. So you use it in the wrong way. 

>
>    - This force very restricted use case for qualify and one should take 
>    care how and where used qualify macro!
>
> That's true. 

It should be used only where it solves the problem it was designed for. 

There are some rules that you found out and some you missed.

1) <<qualify baseName>> only creates the same name if it is *called within 
the same tiddler*
2) If a qualify state name should survive transclusion in needs to be *written 
to a variable*
3) If you need human *predictable *state-names, you need to *create them on 
your own*
4) If <<qualify>> causes problems, you probably can't use it.

add 1) 
If you have a look at the TW core code which uses the <<qualify xxx>> macro 
you'll find this pattern: 

<$button popup=...> ... <$reveal state=...>  *OR *<$button set=...> ... 
<$reveal state=...>

eg: in $:/core/ui/TagTemplate 
<https://tiddlywiki.com/#%24%3A%2Fcore%2Fui%2FTagTemplate>

<$button popup=<<qualify "$:/state/popup/tag">> ...>

and some lines later you'll find: 

<$reveal state=<<qualify "$:/state/popup/tag">> type="popup" ... />

add 2)
Whenever a transclusion is used later in the code <<qualify xxx>> output is 
set to a variable. 
eg: $:/core/ui/ViewTemplate 
<https://tiddlywiki.com/#%24%3A%2Fcore%2Fui%2FViewTemplate>

<$vars storyTiddler=<<currentTiddler>> tiddlerInfoState=<<qualify 
"$:/state/popup/tiddler-info">>>
.....
</$vars>

The transcluded templates need to use the variable names instead of the 
macro. above eg: tiddlerInfoState

add 3)
Either use 2)  or create it like this: 

\define folded-state()
$:/state/folded/$(currentTiddler)$
\end
<$vars storyTiddler=<<currentTiddler>> ....>>
.....
</$vars>

See: folded-state also from: $:/core/ui/ViewTemplate 
<https://tiddlywiki.com/#%24%3A%2Fcore%2Fui%2FViewTemplate> 
Internally variables and \define xx() are handled very similar.

add 4)
see add 3)

------------------------

More to follow ....

have fun!
mario

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/e63f581e-9c88-4ccd-a9a0-e61bcb17fd10%40googlegroups.com.

Reply via email to