Appending text to a tiddler

321 views
Skip to first unread message

Scott Kingery

unread,
Dec 6, 2018, 12:45:40 PM12/6/18
to TiddlyWiki
I'm trying to build a button to append text to a tiddler. Thing is, I want the name of the tiddler to by dynamic. Stephan has the example I'm building on here: http://skeeve.tiddlyspot.com/ . That code is:

\define appendButton(now, add)
 
<$button set="Target" setTo="$now$$add$">append</$button>
\end

<$edit-text  tiddler="$:/
temp/Append"/>
<$macrocall $name="
appendButton" now={{Target}} add={{$:/temp/Append}}/>

---
{{Target}}

That appends a tiddler called Target.

My attempt is almost there. I'm able to dynamically set the the tiddler I want to send the text to and that bit is working but it isn't appending. I'm trying to figure out how to dynamically set the now={{Target}} bit.

My non working attempt is here.
\define appendButton(target, now, add)
 
<$button set=$target$ setTo="$now$$add$<br>">append</$button>
\end

<$wikify name="thisproj" text={{!!project}}>
<$wikify name="projnotes" text='<<thisproj>> Notes'>

{{||$:/
timer}}

<$edit-text  tiddler="$:/temp/Append"/>
<$macrocall $name="appendButton" target="<<projnotes>>" now=<<projnotes>> add={{$:/temp/Append}}/>

Any ideas appreciated.

Thanks,
Scott

Scott Kingery

unread,
Dec 6, 2018, 6:59:21 PM12/6/18
to TiddlyWiki
Decided to switch things up and got closer to my goal.
Made a macro:
\define updtTID(param:"", btn-caption:"Add a Note", color:"#8058A5")
<$button style="color:$color$; fill:$color$; margin-bottom:3px;">
{{$:/core/images/new-button}} $btn-caption$


<$wikify name="master" text="{{$param$}}{{$:/temp/Append}}">
<$action-setfield $tiddler="$param$" text=<<master>>/>
<$action-setfield $tiddler="$:/
temp/Append" text=""/>
</$wikify>
</$button>
\end

Then calling this macro:
<$wikify name="thisproj" text={{!!project}}>
<$wikify name="projnotes" text='<
<thisproj>
> Notes'>


<$edit-text  tiddler="$:/temp/Append"/>


<<updtTID param:$(projnotes)$>>

Now the only thing missing is a way to add a <br> to the end each time the text is appended.

Mohammad

unread,
Dec 7, 2018, 2:12:21 AM12/7/18
to TiddlyWiki
Hello Scott!
 This is not a very good solution, but works for you!

Change the line

<$wikify name="master" text="{{$param$}}{{$:/temp/Append}}">



with


<$wikify name="master" text="{{$param$}}&#10;&#10;{{$:/temp/Append}}">


--Mohammad

Mohammad

unread,
Dec 7, 2018, 2:26:40 AM12/7/18
to TiddlyWiki
Scott,
 The problem with your solution is: Some wikitext formatting in your main tiddler or $:/temp/Append
 will not work and every time you use updtTID   macro those formatting will be removed or wikified. For example try to append

This is a ''Text''.

Or

```
 y=sx
```


This is another Test. `y` is a variable.



And if for example your main tiddler contains


This text has been transcluded from`test`:{{test}}

After appending, you will not have {{test}} but its wikified value has been inserted!


-Mohammad

Scott Kingery

unread,
Dec 7, 2018, 1:29:08 PM12/7/18
to tiddl...@googlegroups.com
Mohammad,
Thanks for the tip on using the code for <br>. It works great.

You make a good point about wikifying the text I am passing. It may not be a big problem for the simple case I have for this current project but it does make sense to consider changing my solution.

--
You received this message because you are subscribed to a topic in the Google Groups "TiddlyWiki" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/tiddlywiki/XSnQsePRSVU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to tiddlywiki+...@googlegroups.com.
To post to this group, send email to tiddl...@googlegroups.com.
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/c447d8f0-3dfe-4e09-bf41-98e3bae92525%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages