template for translcusion of wiki content

103 views
Skip to first unread message

Jean-Pierre Rivière

unread,
Apr 15, 2020, 6:28:23 PM4/15/20
to TiddlyWiki
Following my previous question, I have been able to fully uderstant what answers I got. Thanks again for your help.

I'm now able to define a macro for transcluding a wikified tiddler as I wish, but this macro must have the required html within its code. A better alternnative would be to use a template, a I was suggested.

The templates I saw use the view gadget. The view gadget is unable to translate a wiki contents into html and as such it is useless for me.

The transclude widget does that. But my macro already uses it, with a prescription of a template, so the template has not to use a transclude widget. If I understand the mechanism correctly, the view gadget (of the template) would import ra<w wiki contents that the transclude widgety (of the macro) would interpret.

But alas... it does not seems to work.

So here's my attempts. I'm using the latest tw5 5.1.22 (BTW I can't find a way to get the version number of a single file tiddlywik, besides $:/built which doesn't ?):

1) tiddler "$:/templates/ImportantTip", not tagged:
<aside class="tip-block"><div class="tip-icon">{{$:/core/images/tip}}</div> <$view tiddler=<<currentTiddler>> field="text"/></aside>

2) tiddler "tipper" tagged "$:/tags/Macro":
\define !tip(tiddler)
<$tiddler tiddler="$tiddler$"><$transclude mode="block" tiddler="$:/templates/ImportantTip"/></$tiddler>
\end

\define !tipDirect(tiddler)
<$tiddler tiddler="$tiddler$">
<aside class="tip-block"><div class="tip-icon">{{$:/core/images/tip}}</div><$transclude mode="block"/></aside></$tiddler>
\end

3) tiddler "tip" not tagged (tw5 content type):
This is a //wiki// content much ''important'' for this [[project]]!

4) tiddler "testing" not tagged:
!! direct inclusion without template
<<!tipDirect "tip">>
!! inclusion with template
<<!tip "tip">>

Results: The "testing" tiddler is rendered thus (parenthesis are my description of what you get, in case you see only undecorated text):

direct inclusion without template (written as a title)
This is wiki content much important for this project!
(with "wiki" in italics, "important" as bold and "project" as a wiki link: that's perfect!)
inclusion with template (written as a title)
This is a //wiki// content much ''important'' for this [[project]]!
(that's the raw wiki text: failure)

(note: the tip icon is seen for both transclusions, proof that they really happened)

I have no problem with adding my css style the tw5 way. My problems really are about the final html output.

What error did I do?




PMario

unread,
Apr 15, 2020, 7:52:30 PM4/15/20
to TiddlyWiki
On Thursday, April 16, 2020 at 12:28:23 AM UTC+2, Jean-Pierre Rivière wrote:

So here's my attempts. I'm using the latest tw5 5.1.22 (BTW I can't find a way to get the version number of a single file tiddlywik, besides $:/built which doesn't ?):

There is a <<version>> macro, which will show it.

-m

Jean-Pierre Rivière

unread,
Apr 16, 2020, 6:55:17 PM4/16/20
to tiddl...@googlegroups.com
thank you for the <<version>> macro. My tw5 version is 5.1.22.

BTW, I cannot be successful into transforming the icon into an image link to the tiddler of the displayed tip. Either the icon disappear, ot the target of the link is not there or I have my coding directly written.

\define !tipDirect(tiddler)
<$tiddler tiddler="$tiddler$">
<aside class="tip-block"><div class="tip-icon"><a href="#$tiddler$" alt="tiddler for this tip">{{$:/core/images/tip}}</a></div><$transclude mode="block"/></aside></$tiddler>
\end

is nearly good but the link is not functional (once it opened tiddlers for every word in the title of the tip). More simply I was thinking to code:

\define !tipDirect(tiddler)
<$tiddler tiddler="$tiddler$">
<aside class="tip-block"><div class="tip-icon">[[{{$:/core/images/tip}}|$tiddler]]</div><$transclude mode="block"/></aside></$tiddler>
\end

but the icons is not displayed here.

I also tried

\define !tipDirect(tiddler)
<$tiddler tiddler="$tiddler$">
<aside class="tip-block"><div class="tip-icon">[[{{$:/core/images/tip}}\{{!!title}}]]</div><$transclude mode="block"/></aside></$tiddler>
\end

but the link is to "{{!!title}}" and of coure there is no more image.

Mat

unread,
Apr 16, 2020, 7:13:55 PM4/16/20
to TiddlyWiki
Too tired to give elaborate answer but see LinkWidget in the docs. It is what one is supposed to use and takes care of all the stuff, including class, tooltip etc.

<:-)

TonyM

unread,
Apr 16, 2020, 10:55:00 PM4/16/20
to TiddlyWiki
Jean-Pierre,

I am sorry, Your question is to complex and too hard to follow. 
  • Can you attach some tiddlers that demonstrate the problem on tiddlywiki.com?
  • Can you show a simple example of what you are not able to do?
  • view gadget? view Widget?
  • If you asked what you want rather than showing us how you have tried to get it, it may be easier for us to help.
  • Just saying something does not work is not helpful, what is the "bad" result?
  • If you look behind the scenes in tiddlywiki you can often see how it is done there and emulate it yourself.
Regards
Tony
Reply all
Reply to author
Forward
0 new messages