I often struggle with filter syntax so thanks for the counter-example as I 
find those easiest to learn from.

In playing around with it, there is an interesting subtlety with Mark's 
solution that makes it slightly different/better.

If the template does not already exist:
1) it will not tag the new tiddler with <<currentTiddler>> but because you 
are using the template name as a basename, you are effectively creating the 
template from a blank tiddler. So that may be a preferred behaviour. It 
must be some nuance in how the filter will not continue if the 
[TaskTemplate]get[tags] fails to find something to get tags from and 
addsuffix not working on an empty list.
2) it will not ask for confirmation to delete the new tiddler if you click 
the trash can instead of saving your edit ... must be a consequence of the 
non-draft tiddler not existing yet and the text field being blank
3) it will not create anything if you just cancel out of the draft by 
clicking the X ... once again ... maybe that is the preferred behaviour.

Also, I was trying every operator to see if there was an alternative 
solution to manually wrapping the title with [[ and ]] using 
addprefix/suffix but there doesn't seem to be a replacement for the 
$vars/addprefix<left>/addsuffix<right> construction. I thought that enlist 
would do it but it just grabs the first word of the currentTiddler title. 
Maybe there ought to be an enlist:greedy or enlist:value that interprets 
the entirety of the input as a single title and wraps some [[]] around it.

A slight tweak to Mark's solution to tag with currentTiddler even when 
there is a missing template file (and make the space padding in the $vars 
optional) is:

...
<$action-sendmessage $message="tm-new-tiddler" $param="TaskTemplate" 
tags={{{ [[TaskTemplate]get[tags]] 
+[<currentTiddler>addprefix<left>addsuffix<right>] }}} />
...

It still does 2) and 3) though.

I suspect that you could pack that right into the <$button message= ... 
param=... > like the OP but I don't know how one would format the 
paramObject=. There doesn't seem to be examples in the TiddlyWiki manual 
pages.

/Mike
On Tuesday, December 15, 2020 at 5:34:09 PM UTC-4 Mark S. wrote:

> Yet another approach:
>
> <$button >New Task
> <$vars left=" [[" right="]]" space=" ">
> <$action-sendmessage $message="tm-new-tiddler" $param="TaskTemplate" 
>    tags={{{ 
> [[TaskTemplate]get[tags]addsuffix<left>addsuffix<currentTiddler>addsuffix<right>]
>  
> }}}  />
> </$vars>
> </$button>
>
> Mostly this demonstrates that when you use the <$action-sendmessage> 
> widget, it will bundle up other fields and send them along.
> So you could create different versions of the same button, but that add 
> various fields (date, journal, author, etc.) without changing
> the original template.
>
>
> On Tuesday, December 15, 2020 at 1:31:16 AM UTC-8 vinvi...@gmail.com 
> wrote:
>
>> Hello,
>>
>> I am using WidgetMessage: tm-new-tiddler.
>> https://tiddlywiki.com/static/WidgetMessage%253A%2520tm-new-tiddler.html
>>
>> I have a Template tiddler called "Template1" with fields, tags etc.
>> And a tiddler called "Template1Button" with this code:
>>
>> <$button message="tm-new-tiddler" param="Template1Button">New 
>> tiddler</$button>
>>
>> I transclude tiddler {{||Template1Button}} in different tiddlers. It all 
>> works fine so far.
>>
>> How can I make sure that the newly created tiddler is also automatically 
>> tagged to the tiddler where the button is transcluded?
>>
>> So when I click on the transcluded button in Tiddler1 the new tiddler 
>> should be automatically tagged to Tiddler1. And with Tiddler2 to Tiddler 2 
>> etc.
>>
>> Thank you,
>>
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/872f739e-c038-427e-aa7d-1ade8804a3can%40googlegroups.com.

Reply via email to