[TW5] Bug in reveal widget?

79 views
Skip to first unread message

Stephan Hradek

unread,
Nov 23, 2014, 2:46:48 PM11/23/14
to tiddly...@googlegroups.com
The documentation of the reveal widget says:

defaultDefault value to use when the state tiddler is missing


but then try this:

<$reveal type="match" default="def" text="def">
match
<br/>
</$reveal>
<$reveal type="nomatch" default="def" text="def">
nomatch
<br/>
</$reveal>

Clearly a state tiddler is missing, but the "match" isn't diesplayed. But neither is "nomatch" displayed.

Tobias Beer

unread,
Nov 23, 2014, 2:49:01 PM11/23/14
to tiddly...@googlegroups.com
I see the if else exercise did have it's fruits. :)

Best wishes, Tobias.

Stephan Hradek

unread,
Nov 23, 2014, 3:00:20 PM11/23/14
to tiddly...@googlegroups.com


Am Sonntag, 23. November 2014 20:49:01 UTC+1 schrieb Tobias Beer:

    I see the if else exercise did have it's fruits. :)
    Best wishes, Tobias.

So it is. With the default you could easily create your comparison with different values:

<$reveal type="match" text="$foo$" default="myValue">
do this
</$reveal>




And maybe an idea for after the end of the moratorium: "Poor man's switch":

<!-- NOT ACTUAL CODE -->
<$switch>
  <$reveal type="match" text="$foo$" default="myValue">
    do this
    <$break/>
  </$reveal>
  <$reveal type="match" text="$foo$" default="myOtherValue">
    do this instead
    <$break/>
  </$reveal>
 
<!-- default -->
    do something different
</$switch>




This would also solve the annoying fact that you often have to have 2 reveals with contrary types but same test, just to get the "else" part:

<!-- NOT ACTUAL CODE -->
<$switch>
  <$reveal type="match" ...some comparrison here..>
    do this
    <$break/>
  </$reveal>
 
<!-- default -->
    otherwise do this
</$switch>



 

Jeremy Ruston

unread,
Nov 23, 2014, 3:01:48 PM11/23/14
to TiddlyWikiDev
Hi Stephan

The reason why these examples don't work is because the "state" attribute isn't specified.

<$reveal type="match" default="def" text="def">
match<br/>
</$reveal>
<$reveal type="nomatch" default="def" text="def">
nomatch<br/>
</$reveal>

Best wishes

Jeremy.


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



--
Jeremy Ruston
mailto:jeremy...@gmail.com

Stephan Hradek

unread,
Nov 23, 2014, 3:07:15 PM11/23/14
to tiddly...@googlegroups.com, jeremy...@gmail.com


Am Sonntag, 23. November 2014 21:01:48 UTC+1 schrieb Jeremy Ruston:
Hi Stephan

The reason why these examples don't work is because the "state" attribute isn't specified.

I understand why it does not work and simply putting state=<<qulify>> helps.

But the state attribute isn't documented as mandatory. Instead of marking it as mandatory, I would like to see a missing state attribute be handled the same way a missing state tiddler would be handled. See the thread in the other group: https://groups.google.com/forum/#!topic/tiddlywiki/VX1qnNb48PI

Did you also consider the "poor man's switch"?

Jeremy Ruston

unread,
Nov 23, 2014, 3:12:00 PM11/23/14
to Stephan Hradek, TiddlyWikiDev
> Did you also consider the "poor man's switch"?

I think the logic is at the wrong layer. The reveal widgets that are generated by the macro are redundant, in that their status is fixed at the time the macro text substitution is performed. We need the conditional logic within the macro definition.

Best wishes

Jeremy.


Stephan Hradek

unread,
Nov 23, 2014, 3:16:56 PM11/23/14
to tiddly...@googlegroups.com, stephan...@gmail.com, jeremy...@gmail.com


Am Sonntag, 23. November 2014 21:12:00 UTC+1 schrieb Jeremy Ruston:
> Did you also consider the "poor man's switch"?
 
I think the logic is at the wrong layer.
 
I disagree

 
The reveal widgets that are generated by the macro are redundant,

Just this one example is using a macro.

You could as well have it without macros. For example if you want to compare a variable to some values.

I think the possibilities we will be able to use that can't all be forseen now. Would it hurt to handle a missing state attribute like a missing state tiddler?

Stephan Hradek

unread,
Nov 23, 2014, 3:26:04 PM11/23/14
to tiddly...@googlegroups.com, stephan...@gmail.com, jeremy...@gmail.com
You already check for the existance of the state attribute:


if(this.stateTitle) {
               
var state = this.wiki.getTextReference(this.stateTitle,this["default"],this.getVariable("currentTiddler"));

if this is changed to (broken for readability):

var state = this.stateTitle
   
? this.wiki.getTextReference(this.stateTitle,this["default"],this.getVariable("currentTiddler"))
   
: this["default"];

We would have it, wouldn't we?




Stephan Hradek

unread,
Nov 23, 2014, 3:40:58 PM11/23/14
to tiddly...@googlegroups.com, jeremy...@gmail.com


Am Sonntag, 23. November 2014 21:01:48 UTC+1 schrieb Jeremy Ruston:
The reason why these examples don't work is because the "state" attribute isn't specified.

Just nitpicking and kidding you a bit:

This doesn't work either:

<$reveal type="match" state="" default="def" text="def">
match
<br/>
</$reveal>
<$reveal type="nomatch"
state="" default="def" text="def">
nomatch
<br/>
</$reveal>




Stephan Hradek

unread,
Nov 24, 2014, 1:40:26 AM11/24/14
to tiddly...@googlegroups.com, stephan...@gmail.com, jeremy...@gmail.com

Tested yesterday and proposed as pull request #1131 now..

Stephan Hradek

unread,
Nov 24, 2014, 8:20:47 AM11/24/14
to tiddly...@googlegroups.com
Jeremy merged my pull request. So reveal can soon be used with variables too.

Tobias Beer

unread,
Nov 24, 2014, 10:16:50 AM11/24/14
to tiddly...@googlegroups.com
Jeremy merged my pull request. So reveal can soon be used with variables too.

Which pull request was that?

Best wishes, Tobias. 

Stephan Hradek

unread,
Nov 24, 2014, 10:46:20 AM11/24/14
to tiddly...@googlegroups.com


Am Montag, 24. November 2014 16:16:50 UTC+1 schrieb Tobias Beer:
Jeremy merged my pull request. So reveal can soon be used with variables too.

Which pull request was that?

#1131... Mentioned somewhere here in the thread.

David Someone

unread,
Aug 20, 2016, 2:01:52 PM8/20/16
to TiddlyWikiDev
Could I trouble you to expand on that? How do we use reveal with variables? The help Tiddler hasn't been updated.

I'm assuming something like this?

<$reveal state=<<myVariable>> text="true">

...but that doesn't work.

Thanks!

Eucaly J

unread,
Aug 28, 2016, 1:03:02 AM8/28/16
to TiddlyWikiDev
Did you check the example?

http://tiddlywiki.com/#RevealWidget


David Someone於 2016年8月21日星期日 UTC+8上午2時01分52秒寫道:
Reply all
Reply to author
Forward
0 new messages