TW5 can't pass a tiddler w/ spaces as a macro param

136 views
Skip to first unread message

myst...@gmail.com

unread,
Jul 22, 2017, 12:38:45 PM7/22/17
to TiddlyWiki

I saw a similar post addressing this for $variable$ types.
My problem is that i am using <$set> w/ a  filter to get the tiddler title based on a name passed to it, which restricts me to the <<variable>> usage.

The below macro works great if the title passed is a single word such as 'Alarmed'. the modal will pop up w/ the tiddler.
If i pass a mult-word title such as "Alarmed and Dangerous" the modal will fail.

Any suggestions much appreciated.
  --Kenn


\define modal_link(title:none)
<$set name="tit" value=$title$>
<$set name="myTid" filter='[!is[system]regexp:<tit>]'>
<$button>
<$action-sendmessage $message="tm-modal" $param=<<myTid>>/>
<<myTid>>
</$button>
</$set>
</$set>
\end

PMario

unread,
Jul 22, 2017, 1:36:23 PM7/22/17
to TiddlyWiki
Hi,

Try this:

<$set name="tit" value="""$title$""">

see: http://tiddlywiki.com/#Macro%20Calls%20in%20WikiText

-m

Eric Shulman

unread,
Jul 22, 2017, 1:41:31 PM7/22/17
to TiddlyWiki
On Saturday, July 22, 2017 at 9:38:45 AM UTC-7, myst...@gmail.com wrote:
I saw a similar post addressing this for $variable$ types.
My problem is that i am using <$set> w/ a  filter to get the tiddler title based on a name passed to it, which restricts me to the <<variable>> usage.
The below macro works great if the title passed is a single word such as 'Alarmed'. the modal will pop up w/ the tiddler.
If i pass a mult-word title such as "Alarmed and Dangerous" the modal will fail.

\define modal_link(title:none)
<$set name="tit" value=$title$>

Put quotes around $title$, like this:

   <$set name="tit" value="$title$">

the $param$ syntax is a *lexical subtitution* done upon entry to the macro.  Thus, if you pass in a parameter value containing spaces (e.g., "two words"), then the substitution, without the surrounding quotes, would be:

   <$set name="tit" value=two words>

resulting in a value of tit="two", with "words" being ignored, rather than resulting in tit="two words"
 
<$set name="myTid" filter='[!is[system]regexp:<tit>]'>
<$button>
<$action-sendmessage $message="tm-modal" $param=<<myTid>>/>
<<myTid>>
</$button>
</$set>
</$set>
\end

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

myst...@gmail.com

unread,
Jul 23, 2017, 1:38:28 PM7/23/17
to TiddlyWiki
So I have hit another stopping block.

one of the things this modal needs to do, is pass a tiddler title that has a transclusion in it.
I read a previous post about needing to defer  the transclusion, and i believe I have done so.. but it refuses to work.

The first call to the macro works great as i have manually typed in the tiddler title.
The second call which uses a {{!!field}} transclusion fails.

If i remove the > from the <$action-sendmessage> (i do this a lot as a debug step),
The HTML even loks the same between them:

      <$action-sendmessage $message="tm-modal" $param="Spell/DnD5e/Animal Friendship" /



Here is the code:

\define modal_link(name tiddler)
<$macrocall $name="render_modal_link" title="""$name$""" tidd="""$tiddler$"""/>
\end

\define render_modal_link(title:none tidd:"")
<$button>
<$action-sendmessage $message="tm-modal" $param="$tidd$" />
$title$ -
</$button>
\end

<<modal_link "Animal Friendship" "Spell/DnD5e/Animal Friendship">>

<<modal_link "{{!!slot0}}" "Spell/DnD5e/{{!!slot0}}">>

myst...@gmail.com

unread,
Jul 24, 2017, 8:50:56 PM7/24/17
to TiddlyWiki
Any Suggestions? Please? :)

Thomas Elmiger

unread,
Jul 27, 2017, 2:29:59 PM7/27/17
to TiddlyWiki
I think you should send your tiddler name through the wikify widget: http://tiddlywiki.com/#WikifyWidget

Good luck ;–)

Mark S.

unread,
Jul 27, 2017, 3:07:24 PM7/27/17
to TiddlyWiki
You're trying to concatenate and pass a parameter. Usually when you need to concatenate, you need to invoke a macro. But you already have a macro, so you can revise that one:

\define modal_link(name prefix)
<$macrocall $name="render_modal_link" title="""$name$""" tidd="""$prefix$/$name$"""/>
\end

and then, maybe, invoke it like this:

<<modal_link {{!!slot0}} "Spell/DnD5e">>

if that doesn't work, you might need  to invoke it as a macro call:

<$macrocall $name="modal_link" name={{!!slot0}} prefix="Spell/DnD5e"/>

Without seeing your code, it's hard to know for sure what will work, what will need to be done. Hopefully this will do it ;-)

Mark
Reply all
Reply to author
Forward
Message has been deleted
0 new messages