Why doesn't it work?

I'm unsure whether you want $(name)$ to be replaced during creation, or if 
you want to copy `\define code-tiddler() $(name)$` exactly as is, but 
either way, you can include pragma inside the body macro.

\define body()
\define code-tiddler() $(value)$

Dear $(name)$,

I write to inform you that your pet, $(pet)$ has filed for emancipation.
\end


$(value)$ here will remain as-is unless `value` is defined. If it IS 
defined, it'll replace, so you can get either way you want it, I'd think.

On Tuesday, March 24, 2020 at 8:35:19 AM UTC-4, TonyM wrote:
>
> Fibbles,
>
> I have just realized this won't work in the tiddler I create needs to 
> contain a define
> \define code-tiddler() $(name)$
>
> There are many applications it will, but perhaps not this one.
>
> Regards
> 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/3fb99955-f59c-4aae-97d1-15c4c474dfe1%40googlegroups.com.

Reply via email to