Struggling to nest a macro

73 views
Skip to first unread message

Cade Roux

unread,
Oct 17, 2019, 5:33:30 PM10/17/19
to TiddlyWiki
My existing macros allow me to present a transcluded tiddler with an (Edit) link after it and if the tiddler is missing, it presents it as (Missing), so that an editor can create and immediately the tiddler.

So I can do <<trans-edit title:"tiddler to be transcluded">>

and either get:

Transcluded tiddler content (Edit)

or

(Missing)

Now, I want to modify the macro so that it only puts those links in IF we are not in release mode (so casual users who are sent the file to read don't think they are editing anything).  But I know you can't nest macros and it also seems that you can't nest $list widgets?

These are my existing macros.  I tried to wrap the $list widget in trans-edit with another $list widget using a search on a "releasemode" tiddler, but it didn't seem to work.

\define trans-edit-btn(title)
(<$button class="tc-btn-invisible tc-tiddlylink">
<$action-createtiddler $basetitle="$title$" />
<$action-sendmessage $message="tm-edit-tiddler" $param="$title$"/>
Missing
</$button>)
\end

\define edit-btn(title)
(<$button class="tc-btn-invisible tc-tiddlylink">
<$action-sendmessage $message="tm-edit-tiddler" $param="$title$"/>
Edit
</$button>)
\end

\define trans-edit(title)
<$list filter="[title[$title$]] +[has[title]]" emptyMessage=<<trans-edit-btn """$title$""">>>{{$title$}} <<edit-btn """$title$""">></$list>
\end

Mark S.

unread,
Oct 17, 2019, 6:47:50 PM10/17/19
to TiddlyWiki
You can nest list widgets. Maybe show what you were trying to do when nesting your list widgets.

Good luck!

Sycom

unread,
Oct 18, 2019, 12:29:49 AM10/18/19
to TiddlyWiki
1Hello

If I get correctly what you're trying to do I'll recommend using the "variable" parameter of $list when you nest them. Maybe you can use else operator in your filter but the scope is limited.

Greetings

Sylvain
@sycom

Cade Roux

unread,
Oct 18, 2019, 11:16:53 AM10/18/19
to TiddlyWiki
emptyMessage had had no success getting working nested so ended up with this working:

<$list filter="[[releasemode]!is[missing]]">{{$title$}}</$list>
<$list filter="[[releasemode]is[missing]]"><$list filter="[title[$title$]] +[has[title]]" emptyMessage=<<trans-edit-btn """$title$""">>>{{$title$}} <<edit-btn """$title$""">></$list></$list>

Thanks,

Cade
Reply all
Reply to author
Forward
0 new messages