Flibbles,
Thanks, I never intended to be part of relink, only you are working on code
to replace things within the text field according to what surrounds it.
- So I was thinking perhaps you could extract the code to say replace
##placeholder## with "this".
- Just a suggestion ignore at will
But then your suggestion is a good one
\define body()
Dear $(name)$,
I write to inform you that your pet, $(pet)$ has filed for emancipation.
\end
I tested it you can place the above in a tiddler tagged $:/tags/Macro and
it works just as well.
There may be a variation on this trick, so I expect I will find something
even more useful from this lead.
Thanks for the great Tip
Tony
On Tuesday, March 24, 2020 at 1:19:05 PM UTC+11, Flibbles wrote:
>
> This would be outside the scope of Relink, but there are ways to
> programmatically fill out a generated tiddler.
>
> \define body()
> Dear $(name)$,
>
> I write to inform you that your pet, $(pet)$ has filed for emancipation.
> \end
>
> \define createButton()
> <$button tooltip="Create new letter" aria-label="new letter" class=<<tv-
> config-toolbar-class>>>
> <$action-sendmessage $message="tm-new-tiddler" title=<<title>> text=<<body
> >> />
> <$list filter="[<tv-config-toolbar-icons>prefix[yes]]">
> {{$:/core/images/new-button}}
> </$list>
> <$list filter="[<tv-config-toolbar-text>prefix[yes]]">
> <span class="tc-btn-text"><$text text="new letter" /></span>
> </$list>
> </$button>
> \end
>
>
> <$set name="title" value="New Letter">
> <$set name="name" value="Wilson">
> <$set name="pet" value="snuffles">
> <<createButton>>
>
> </$set></$set></$set>
>
>
> This will create a new tiddler. with a variable title, name, and pet.
>
> -Flibbles
>
> On Monday, March 23, 2020 at 9:20:52 PM UTC-4, TonyM wrote:
>>
>> Folks,
>>
>> I have a little project where it would be helpful if I could create a
>> tiddler from a template (for its body) but then replace various content
>> within the text or fields with different values.
>>
>> For example what if the template included ##name## then I had a macro
>> that would replace in the body of the new tiddler
>>
>> - ##name## with Tony
>> - ##icon## with {{<<tiddlername>>||$:/core/images/info-button}}
>> - etc...
>>
>> I imagine if a set of such changes could be triggered by a button and an
>> action widget all the better.
>>
>> I have other ways to achieve this but it would surprise me if the code
>> was not already available somewhere.
>>
>> Any leads would be appreciated
>>
>> Regards
>> Tony
>>
>
--
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 view this discussion on the web visit
https://groups.google.com/d/msgid/tiddlywiki/b508b3cc-46e7-4b13-aa1c-3dc731090a8b%40googlegroups.com.