IT actually sounds like we want something closer to a transcluded-template.
So, we are going to use 1) a tiddler marked as a global macro and 2) a
template tiddler, and 3) a CSS tiddler, 4) a "tip" tiddler.
This example mirrors the "documentation macros" from the TiddlyWiki website.
In any tiddler tagged `$:/tags/Macro`
```
\define !tip(tiddler)
<$tiddler tiddler="$tiddler$"><$transclude
tiddler="$:/templates/importantTip"/></$tiddler>
\end
```
Then in `$:/templates/importantTip` we can have:
```
<div class="tip-block"><div class="tip-icon">{{$:/core/images/tip}}</div>
<$view tiddler=<<currentTiddler>> field="text"/></div>
```
And then we have a tiddler tagged wit `$:/tags/Stylesheet`:
```
.tip-block { border-left: 2px solid #e1e1e8; margin-left: 3em;
padding-left: 0.6em; position: relative; }
.tip-icon { position: absolute; left: -3em; top: 0.2em; }
.tip-icon .tc-image-tip { fill: #5778d8; }
```
Finally in `TiddlerWithTipText` the text field contains:
```
This is a very important tip!
```
Now that is all setup, we can- in any other tiddler we like - call it like
this:
```
Content that sets up context for a user tip.
<<!tip "tiddlerWithTipText>>
```
I have attached a quick screenshot of this in action on TiddlyWiki.com. I
hope this helps demonstrate how combining just a few basic tiddlywiki
concepts can be very powerful.
Some thing to note. In the macro, the `$variable$` text substitution will
only work within the macro, which is why it is not used in the transcluded
template. Instead, we set the <$tiddler> widget in the macro, and then in
the template we call the <<currentTiddler>> variable (set by the $tiddler
macro). If we want to extend this to be more flexible, we could allow the
<<!tip>> macro to take another parameter like so:
```
\define !tip(tiddler, template:"$:/templates/importantTip")
<$tiddler tiddler="$tiddler$"><$transclude tiddler="$template$"/></$tiddler>
\end
```
Now we can call it with one parameter, and it will use the default
template. If we call it with 2 parameters it will use the value of the 2nd
a the template tiddler to transclude.
Best,
Joshua Fontany
[image: ComplexTranscludeMacroDemo.png]
On Tuesday, April 7, 2020 at 3:39:41 PM UTC-7, Jean-Pierre Rivière wrote:
>
> Hi!
>
> I'm using tiddlywiki v5.1.21 to produce some rulsets. I'd like to have
> some special kind of tiddlers for tips and warning.
>
> Basically, I was thingking of a simple transclusion like:
>
> {{look at that tip}}
>
> which doe the trick, but you cannot see it's a tip. So I thought doing
> that:
>
> <aside>
> {{look at that tip}}
> </aside>
>
> (with a few css in the bargain). BUT the tranclusion in that xase is
> incomplete: the transcluded tiddler has not any paragraph (code <p>...</p>)
> even though is was coded so as to to have several ones. Which means it is
> useless. Even a simple <div> has the same failure.
>
> I've tried looking for transclusion in this group. I notably saw tw5
> magick trick for "full-enhanced"
> http://tw5magick.tiddlyspot.com/#Another%20TOC%20example but then I got
> an error: 'Recursive transclusion error in transclude widget'. My code is
> below:
>
> ! <span title="Edit section"><$button message="tw-edit-tiddler"
> param={{!!title}} class="btn-invisible"><$view
> field="title"/></$button></span>
> <$transclude/>
>
> (a direct paste of the original, in a tiddler named "full-enhanced").
>
> I also poke at
> https://groups.google.com/forum/#!topic/TiddlyWiki/rsoiC7DdnsE which has
> some nice TOC tricks but far above my level of understanding.
>
>
>
--
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/93832ae0-dae4-4198-b2bc-1b14348c92fe%40googlegroups.com.