I have a macro as below. When you call it with a tiddler name, it will
check to see if the tiddler exists
- If exist it will navigate to that tiddler
- If not, it will call another macro to create it and then navigate to it
\define create-note(tname)
<$set name="myTid" filter="[[$tname$]addsuffix[-math]]">
<$list filter="[title<myTid>] +[has[title]]"
variable="newTid"
emptyMessage=<<tidller-not-exist $tname$>>
>
<$action-navigate $to=<<newTid>> />
</$list>
</$set>
\end
\define tiddler-not-exist(parent)
<$action-setfield
$tiddler= {{{$(myTid)$}}}
text="Hi, this is a new note"
tags="notes"
/>
<$action-navigate $to={{{$(myTid)$}}} />
\end
The problem is the macro fails when you pass a name with space as parameter
to it. It create the tiddler and overwrite the existed one!
- Works
<$button> Hi
<<create-note "Hi">>
</$button>
- Fails
<$button> Hello there
<<create-note "Hello there">>
</$button>
--
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 post to this group, send email to [email protected].
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/78068bf4-155e-46ed-aa66-2d064fe975c4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.