I’d like to transclude in a new Tidder (Test) with a macro the content of Lorem with eg. h1 (all until h2).
I this case Lorem has more ‘sections’ with h1 → a pulldown of all h1 should be listed to choose.
I have a feeling most replies here will be that you are going about it backwards.
It makes more sense, given how TiddlyWiki works, to put a paragraph like what you have contained in the green rectangle, in a separate tiddler, and transclude it here in the Lorem tiddler and also in Test and anywhere else where it needs to be transcluded.
There is no way to transclude only a portion of the text field of a tiddler, and so transcluding part of Lorem in a separate tiddler like Test can’t be done.
Think of most tiddlers as paragraphs or blocks, and some tiddlers as articles that combine those blocks in different ways through transclusion.
Have a look at @Mohammad’s section editor plugin, it allows you to edit sections within a single tiddler as delimited by the headings. It is one of the few examples of handling parts of a single tiddler differently to the whole tiddler.
This is not an answer to your question but may lead to one.
@StS I think there may be value in describing the activity you hope to make easy without reference to any code, because there may be more than one way to achive what your want.
If you have a long written article in one tiddler, you won’t split it up to extra tiddlers to have the possibility to transclude it. There a some use cases for that.
If you don’t want h2 h3 below h1, you can transclude only a block of text under h1…Or we can think of a way to transclude thing between (and including) two anchors.
Hi Stefan, I hope you didn’t interpret my comment as criticism. I was just pointing out that your way of going about kind of goes against the grain of how TW works, so maybe reframing the idea might be a better approach.
You wrote: “If you have a long written article in one tiddler, you won’t split it up to extra tiddlers to have the possibility to transclude it. There a some use cases for that.”
My answer would be, Why wouldn’t you split it up? That is precisely what the excise button is for. To break up longer texts into their shorter components, especially if some of those components can be used in multiple places.
I think at times we all long for “splicing” of tiddlers, something that TW classic had. But since that is not possible in TW now, I think the best approach is looking at things backwards and letting the “splices” be external to the tiddler as separate little tiddlers.
One objection to using transclusion would be that when in the longer article tiddler it is not easy to open the transcluded tiddler. But there is a way around that: transclusion via templates. {{my tiddler||my template}}, where the template includes an unobtrusive link to the tiddler off in the corner.
Here is one I use that would work for your example. I think it was Eric who worked this up for me.
Create a tiddler entitled EditLink, and add the following as text. Then use {{||EditLink}} as your transclusion by template. It will put the tiddler title as a link, a button to edit the tiddler, and transclude the contents. If you don’t want the title as link, just change <$link/> to <$view field="title"/> and format as needed.
The tiddler EditLink itself will look horrible, like a recursion. But the results work great. There is also CSS that can float the edit button all the way to the right, but I would have to do some digging to find it.
For the do not print CSS, you can add a stylesheet tiddler with the following:
plus a second EditLink (EditLink 1), with only transclusion plus the edit button off to the right,
the CSS for float right,
and the CSS for do not print.
Download the json file, then drag it into your TW, and create a tiddler that transcludes another tiddler with {{||EditLink}} and {{||EditLink 1}} to compare the two ways of transcluding.
As Dave mentioned: A tiddler should be the smallest reusable unit
Tiddlers should be used to compose longer stories
I think the main problem with the tiddler philosophy is, that we do not really have the right editor tooling, to make it convenient. Creating 1 tiddler per heading-section or even 1 tiddler per paragraph is a nightmare at the moment.
The streams-plugin is the closest UI that uses the tiddler philosophy. But not everyone wants to read their text as an outline.
Outlines are great for brainstorming – Taking fast notes in a meeting or while watching a video. But I think outlines always need several more refactoring steps.
For new users prose text with headings in 1 tiddler is easy to create, easy to be consumed and transferred as is.
TLDR; The current parse-tree contains a lot more info as the parse-tree from 2014. The parse-tree is cached. I think the possibility to transclude tiddler sections in a performant way should be reviewed again. May be as a plugin
Another method for creating transcludable “named subsections” of a long tiddler (e.g, “Lorem”) is to wrap each subsection within a macro definition, and then invoke the macros to render the content, like this:
\define lorem_ipsum()
!!Lorem ipsum
blah blah blah
\end
\define aenean_blandit()
!!Aenean blandit
more blah blah blah
\end
<<lorem_ipsum>>
<<aenean_blandit>>
Then, you can invoke any of those macros in another tiddler (e.g. “test”) by importing the “Lorem” tiddler, like this:
\import Lorem
some content in test
<<lorem_ipsum>>
some more content in test
Tiddler slices, tiddler sections and TagglyTagging from MPTW (Monkey Pirate TiddlyWiki) where the main features that initially drew me into Tiddlywiki.
Given @DaveGifford’s idea, @EricShulman’s macro. @pmario’s reflection on gaps and some ideas I am exploring perhaps there is an approach.
Have a look at the macro function of the excise tool and Concider other macros.
The idea would be an editor toolbar button or more, that takes selected text or a named tiddler and creates a content macro and appends it elsewhere, but imports it here. This can handle alternative options like heading sections etc…