TW5 can't pass a tiddler name with spaces correctly as a macro parameter

74 views
Skip to first unread message

Vayu Asura

unread,
Apr 24, 2017, 12:42:20 PM4/24/17
to TiddlyWiki
I have this defined

\define failed(tiddler:<<CurrentTiddler>> value:"Failed")
<$radio tiddler=$tiddler$ field="Status" value=$value$> $value$ </$radio>
\end


\define passed(tiddler:<<CurrentTiddler>> value:"Passed")
<$radio tiddler=$tiddler$ field="Status" value=$value$> $value$ </
$radio>
\end

 
when I try to call

|[[System Usage]]|<<failed tiddler: "System Usage">>|<<passed tiddler: "System Usage" >>|



to modify "System Usage" tiddler it modifies "System" tiddler instead.

Other parameters containing spaces work fine. Is that a bug or am I doing something wrong? If tiddler name I'm passing contains no spaces, it works fine.

Tried different quotes and escapes ("",'',"""""",{{}},<<>>)  to no effect. Either still modifies 'System' tiddler or bugs.

Is there a workaround besides changing tiddler name to 'SystemUsage' as I'd like to avoid that?

Eric Shulman

unread,
Apr 24, 2017, 1:09:08 PM4/24/17
to TiddlyWiki
On Monday, April 24, 2017 at 9:42:20 AM UTC-7, Vayu Asura wrote:
I have this defined
\define failed(tiddler:<<CurrentTiddler>> value:"Failed")
<$radio tiddler=$tiddler$ field="Status" value=$value$> $value$ </$radio>
\end
 when I try to call
|[[System Usage]]|<<failed tiddler: "System Usage">>|<<passed tiddler: "System Usage" >>|
to modify "System Usage" tiddler it modifies "System" tiddler instead.

Macro parameters work by substitution.  When the macro is invoked, all parameter references within the macro (e.g., $variablename$) are automatically replaced by their passed in values.  Thus, when you invoke
<<failed tiddler:"System Usage">>
this line of the macro
<$radio tiddler=$tiddler$ field="Status" value=$value$> $value$ </$radio>
results in the following syntax
<$radio tiddler=System Usage field="Status" value=failed> $value$ </$radio>

The problem is that there aren't any quotes around the 'tiddler' param in the <$radio> widget, so the space in the value appears to be a delimeter, making "Usage" into a separate param which lacks the "name=" syntax, and is thus ignored.  The result is as you noted: the tiddler title being applied ends with the first space, and the remainder of the title is ignored.

To correct this, simply add some quotes surrounding the params in the <$radio> widget, like this:
<$radio tiddler="$tiddler$" field="Status" value="$value$"> $value$ </$radio>
which results in the following syntax being generated by the macro:
<$radio tiddler="System Usage" field="Status" value="failed"> failed </$radio>

That should do it.  Let me know how it goes.

enjoy,
-e
Eric Shulman
TiddlyTools.com - "Small Tools for Big Ideas!" (tm)
InsideTiddlyWiki: The Missing Manuals

Vayu Asura

unread,
Apr 24, 2017, 1:36:19 PM4/24/17
to TiddlyWiki
Thanks. That was the issue. However that caused another issue - default to <<CurrentTiddler>> stopped working as it parses variable as plain text thus modifying tiddler called '<<Current Tiddler>>' by default. 
Reply all
Reply to author
Forward
0 new messages