On Thursday, February 4, 2016 at 2:58:35 PM UTC-8, David Allen wrote: > > Actually, let me correct that. What I showed is actually working fine. > What's not working is when I try to pass a variable created by a list > widget into a macro when the tiddler stored in currentTiddler contains > spaces in its title. I'm doing the following: > > <$macrocall $name="ezlink" input=<<currentTiddler>>/> > > \define ezlink(input) >> <$link to=$input$>$input$</$link> >> \end >> > summary: you need to add quotes around $input$ when used as a parameter in a widget... details:
In the $macrocall, you correctly set input=<<currentTiddler>> ... where the <<...>> syntax retrieves the value from the variable. However, when the macro is invoked, any embedded variables (e.g., $input$) are replaced by the corresponding value passed to the macro. Thus, in your macro, if value of the input param is FOO, then the macro output is <$link to=FOO>FOO</$link> In contrast, if the input value is FOO BAR, then the macro output is <$link to=FOO BAR>FOO BAR</$link> Notice that, although the *text* of the link is FOO BAR, the parameter in the $link widget only recognizes the value FOO (i.e., up to the first space). The remainder of the value is simply treated as another widget param -- one that is badly formed, as it doesn't follow the name="value" (or name=<<variable>>... or name={{reference}}) syntax. As noted above, the fix is to add quotes when assembling the $link widget params, like this: <$link to="""$input$""">$input$</$link> This ensures that the resulting output encloses the parameter so it is treated as a single value that contains quotes, rather than two separate params; i.e., <$link to="""FOO BAR""">FOO BAR</$link> Note that I've used the *tripled* quotes syntax around the param value (a TW5 extension to the HTML syntax). This ensures that if the param value contains a regular quote ("), it won't be treated as the ending delimiter for the value. i.e., the following syntax: <$link to="$input$">$input$</$link> would result in an invalid result when passed FOO"BAR: <$link to="FOO"BAR">FOO"BAR</$link> Notice how the embedded quote following FOO *ends* the parameter value, leaving BAR" as invalid junk, but when triple-quoting, the result would be <$link to="""FOO"BAR""">FOO"BAR</$link> which allows the TW5 core to treat the embedded quote as just a regular character. QED. enjoy, -e Eric Shulman TiddlyTools / ELS Design Studios InsideTiddlyWiki: The Missing Manuals -- 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 tiddlywiki+unsubscr...@googlegroups.com. To post to this group, send email to tiddlywiki@googlegroups.com. Visit this group at https://groups.google.com/group/tiddlywiki. To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/7120e4ff-2be2-42c0-b04c-a0a8b78d8783%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.