How can I use the tm-new-tiddler action message to create a new Tiddler with both text and dynamic content?

317 views
Skip to first unread message

Douglas Counts

unread,
Oct 13, 2016, 2:09:01 PM10/13/16
to TiddlyWiki
Okay, the following works providing me with four bulleted list items followed by an empty line and then my page footer:

<$button>
<$action-sendmessage $message="tm-new-tiddler" title="This is newly created tiddler" tags="OneTag [[Another Tag]]" text="* Line One
* Line Two
* Line Three
* Line Four

{{PageFooter}} "/>
New Tiddler
</$button>

However if I try to add dynamic content, like generating the current date as a bulleted list item, then the following code fails:

<$button>
<$action-sendmessage $message="tm-new-tiddler" title="This is newly created tiddler" tags="OneTag [[Another Tag]]" text="* Line One
* Line Two
* <<now "Today is DDth, MMM YYYY">>
* Line Four

{{PageFooter}} "/>
New Tiddler
</$button>

How do I do this without having a pre-existing template?

Thank you

Tobias Beer

unread,
Oct 13, 2016, 4:57:31 PM10/13/16
to TiddlyWiki
Hi Douglas,

Try to wrap your text field in either """ or '

Best wishes,

Tobias.

Douglas Counts

unread,
Oct 13, 2016, 6:04:27 PM10/13/16
to TiddlyWiki
That fixes one of the problems and now it works but it appears that the date would be constantly changing over time because the macro but not the generated date is getting transferred to the New Tiddler.

I'm trying to have the date macro run upon New Tiddler creation where the date, but not the macro itself, is contained within the New Tiddler.

The example below does this:


But I can't get the date generated when there is other text contained within the example.  I was exploring using several lines to see if I could get that to work because I want to be able to place header text and footer text on the New Tiddler.  I fixed the string wrapping problem like you suggested but now the macro itself gets transferred to the New Tiddler's content instead of the generated date. 

Anyone know how to get the now macro to run on New Tiddler creation when there is other text surrounding it?  Specifically if that text contains transclusion content like my {{PageFooter}} section.  I would like to know how to get the now macro to run immediately but not the PageFooter transclusion which needs to have transclusion happen later upon viewing.  I want the footer to be dynamic but have the date generated just that one time..

Any one have a suggestion?

Tobias Beer

unread,
Oct 14, 2016, 2:49:23 AM10/14/16
to TiddlyWiki
Hi Douglas,

The now macro won't do that.

For TWC there was such a plugin.
Not sure it exists for TW5 just yet.
In general, there should possibly be some kinds of hooks
one could leverage in a plugin to do that sort of thing.

However, you can use the ViewWidget,
to show when each tiddler was created or modified:

http://tiddlywiki.com/#ViewWidget

Best wishes,

Tobias.

Douglas Counts

unread,
Oct 14, 2016, 4:56:40 AM10/14/16
to TiddlyWiki
Actually, I got this to work properly by moving the desired content surrounding the now macro actually into the now macro. 

So my text= section appears as follows:

text=<<now "* Line One
* Line Two
* Today is DDth, MMM YYYY
* Line Four

{{PageFooter}}
">> />

This gives me the desired content of:

* Line One
* Line Two
* Today is 14th, October 2016
* Line Four

{{PageFooter}}

where the date is generated immediately but the transclusion still works properly.

Thanks for your suggestions while I worked this out.

PMario

unread,
Oct 14, 2016, 5:17:02 AM10/14/16
to TiddlyWiki
Interestin approach. IMO the wikify widget would have been an option too.
see: http://tiddlywiki.com/#WikifyWidget
-m
Reply all
Reply to author
Forward
0 new messages