Add extra elements to a typed list that has been transcluded?

121 views
Skip to first unread message

si

unread,
Aug 8, 2020, 2:01:41 PM8/8/20
to TiddlyWiki
Hi everyone!

I have a typed list in a tiddler:

# First entry
# Second entry
# Third entry

I want to transclude it into another tiddler, and then add additional elements to the list:

{{List Tiddler}}
# Fourth entry

Obviously this doesn't work - it just starts a new list. Is there a convenient way to do this?

Thanks in advance for your help.

Eric Shulman

unread,
Aug 8, 2020, 2:59:18 PM8/8/20
to TiddlyWiki
On Saturday, August 8, 2020 at 11:01:41 AM UTC-7, si wrote:
I have a typed list in a tiddler:
# First entry
# Second entry
# Third entry
I want to transclude it into another tiddler, and then add additional elements to the list:

It's not pretty, but this will work:
<$vars newline="
">
<$vars list={{List Tiddler}}>
<$vars list={{{ [
<list>addsuffix<newline>addsuffix[# Fourth entry]] }}}>
<$vars list={{{ [
<list>addsuffix<newline>addsuffix[# Fifth entry]] }}}>

<
<list>>

1) The first $vars defines a literal newline character (note the line break in between quotes is essential!)
2) The next $vars fetches the list content from the other tiddler
3) Each subsequent $vars appends a newline plus another numbered entry
4) The <<list>> shows the result (note the linebreak before this line is also essential)

As an alternative, let's suppose you have two source tiddlers, "List One" and "List Two",
where "List One" contains:
# First entry
# Second entry
# Third entry

and "List Two" contains:
# Fourth entry
# Fifth entry

Note that each source tiddler must end with a newline.

Then, you can combine these two source lists like this:
<$vars list={{{ [{List One}addsuffix{List Two}] }}}>

<
<list>>

-e

TW Tones

unread,
Aug 9, 2020, 12:08:54 AM8/9/20
to TiddlyWiki
Si,

With this I think there are two key approaches,
  1. Externalise the list items so they can be listed when ever you want, added to and even reordered, if using a tag
  2. Build a sophisticated way to extract list items, such they can be referenced elsewhere
I have plenty of ideas for the second (2) option but expect the first to be the soundest solution.

Some examples of how I may do the second (2) option
  1. Wikify a tiddler into html and extract the lined with `<li>item</li>` tags
  2. Use splitregexp[\n] to extract lines from the other tiddler and detect lines beginning with "*"
  3. Use wikilinks on each item eg 
The first option can be achieved with something like below, even if you don't create the tiddlers.

"First" tiddler
# [[First entry]]
# [[Second entry]]
# [[Third entry]]


"Second" tiddler
# [[Fourth entry]]

<$list filter="[[First]] [[Second]] +[links[]]">
<li><<currentTiddler>></li>
</$list>

But of course such tiddlers can not have other tiddler links in them.

  • I would consider a new tiddler for each thing you wish to address from somewhere else is the best approach, and part of the tiddlywiki philosophy, Use the excise tool
  • I have being playing with excise and combine but some work is needed.
I can imagine a special kind of excise, or a html section that we can extract fragments of tiddlers from would help here, and may be worth developing. That is a few more tools for handling fragments or parts of tiddlers.

Regards
Tony

si

unread,
Aug 10, 2020, 2:11:34 PM8/10/20
to TiddlyWiki
Thanks a lot Eric, that does the trick!

@ TW Tones

I did consider separate tiddlers, but for this specific case I decided against it just because of the difficulty of jumping around to different tiddlers when editing entries in the list.

Of course plugins like saq's streams may be another good option that solve this problem nicely.

TW Tones

unread,
Aug 10, 2020, 8:15:53 PM8/10/20
to TiddlyWiki
Si,

There are ways to do transcludes such that they are easy to edit in the top tiddler, as you say In a way that's what streams and other solutions do.

Actually, inspired by your situation I have an idea for a excise tool with a difference.

Regards
Tones 

TW Tones

unread,
Aug 10, 2020, 11:13:05 PM8/10/20
to TiddlyWiki
I will continue my stream of thought even if it was not what you were looking for Si.

For example

The following in a tiddler called edit-inline
<$set name=state-tiddler value=<<qualify $:/state/edit-inline>> >
<$reveal type="nomatch" state=<
<state-tiddler>> text="edit">
<$button tag="div" tooltip="Click to edit inline" style="cursor:auto; -webkit-user-select:text; -moz-select:text; -ms-select:text; user-select:text;">
      <$action-setfield $tiddler=<
<state-tiddler>> text="edit"/>
      <$transclude tiddler=<
<currentTiddler>>/>
</$button>
</$reveal>
<$reveal type="match" state=<
<state-tiddler>> text="edit">
<$button tag="div" tooltip="Click to edit inline" style="cursor:auto; -webkit-user-select:text; -moz-select:text; -ms-select:text; user-select:text;">
      <$action-setfield $tiddler=<
<state-tiddler>> text="edit"/>
      {{||$:/core/ui/EditTemplate/body/editor}}
</$button><$button tooltip="Click to edit inline">
      <$action-setfield $tiddler=<
<state-tiddler>> text="view"/>
      Close
</$button>
</$reveal>
</$set>

Then when you transclude part of a tiddler
Rather than
{{tiddlername}}
use
{{tiddlername||edit-inline}}
Then click to edit inline

My idea is to make a set of templates you can choose from at excise time.

Regards
Tones
Reply all
Reply to author
Forward
0 new messages