Hi Josiah!
This new version works ALSO with empty tiddlers
\define append-text(tidTitle, text:"", btnLabel:"Append Text", sep:"<br>")
<$button> $btnLabel$
<$list variable="newText"
filter="[<__tidTitle__>get[text]addsuffix<__sep__>addsuffix<__text__>]"
emptyMessage="""<$action-setfield $tiddler=<<__tidTitle__>>
text=<<__text__>> />""" >
<$action-setfield $tiddler=<<__tidTitle__>> text=<<newText>> />
</$list>
</$button>
\end
On Saturday, April 6, 2019 at 2:01:54 PM UTC+4:30, @TiddlyTweeter wrote:
>
> Thanks for the quick response! Very useful tool!
>
> It works well except that if the target Tiddler (in the example TidB) has
> an empty text field it won't get appended to.
>
> Is there a way to get the append working even if the text field is empty?
>
> Many thanks!
> Josiah
>
> Mohammad wrote:
>>
>>
>> You may like the below macro!
>>
>>
>> \define append-text(tidTitle, text:"", btnLabel:"Append Text", sep:"<br>"
>> )
>> <$button> $btnLabel$
>> <$list variable="newText" filter=
>> "[<__tidTitle__>get[text]addsuffix<__sep__>addsuffix<__text__>]" >
>> <$action-setfield $tiddler=<<__tidTitle__>> text=<<newText>> />
>> </$list>
>> </$button>
>> \end
>>
>>
>> *Examples*
>> Test on Tiddlywiki.com. Create two tiddlers, titles TidA and TidB
>>
>> Example 1:
>>
>> <<append-text tidTitle:"TidB" text:"This is another text">>
>>
>> Example 2:
>>
>> <$macrocall $name=append-text tidTitle="TidB" text={{TidA}} sep=" " />
>>
>>
>> Remarks
>> Note changing a field needs some kind of triggering widgets! So, here I
>> used a button!
>>
>> - *tidTitle *gets the title of tiddler you want to append text to it
>> - *text *the text to be appended
>> - *btnLabel*: the label for button
>> - sep: the separator is used when appending text to end of the text
>> of tiddler
>>
>> If you want to append text of a base tiddler use syntax of example 2.
>>
>>
>> I hope other people gives their solutions, comment for a better and more
>> concise macro!
>>
>> --Mohammad
>>
>>
>>
>> On Thursday, April 4, 2019 at 7:05:32 PM UTC+4:30, @TiddlyTweeter wrote:
>>>
>>> The use case is you create a tiddler and realise it would be better
>>> added to another (not via transclusion, rather, the literal content of
>>> "text" is appended to another Tiddler's "text" field.).
>>>
>>> Do you know how to do this?
>>>
>>> Any tips appreciated.
>>>
>>> Best wishes
>>> Josiah
>>>
>>
--
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/39d6243a-6408-4ab9-8b9f-4a9d817b743d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.