[TW5] Transclusion of the tiddler caption as a description for a link

296 views
Skip to first unread message

Łukasz Hirt

unread,
Aug 11, 2015, 3:40:55 PM8/11/15
to TiddlyWiki
Hello guys,

First of all, this is my first post here. I think TW is a great piece of tool, but since I am still beginner I would liek to ask you a question:

I would like to use tiddler's caption as a description of a link. I tried two solutions, one works as expected, another one does not work.
Iw ould like to know why the other one does not work.


SOLUTION 1 - this works as expected > creates link to MY_TIDDLER but displays the caption of that tiddler

<$link to="MY_TIDDLER"> {{MY_TIDDLER!!caption}} </$link>


SOLUTION 2 - this one does not work, WHY ? Instead the caption of MY_TIDDLER it displays {{MY_TIDDLER!!caption}}

[[{{MY_TIDDLER!!caption}}|MY_TIDDLER]]


Thanks in advance for any help.

Regards,
Lukasz

PMario

unread,
Aug 12, 2015, 9:21:11 AM8/12/15
to TiddlyWiki

On Tuesday, August 11, 2015 at 9:40:55 PM UTC+2, Łukasz Hirt wrote:
Hello guys,

First of all, this is my first post here. I think TW is a great piece of tool, but since I am still beginner I would liek to ask you a question:

Hi Lukasz,
Welcome to the club :)
 

I would like to use tiddler's caption as a description of a link. I tried two solutions, one works as expected, another one does not work.
Iw ould like to know why the other one does not work.


SOLUTION 1 - this works as expected > creates link to MY_TIDDLER but displays the caption of that tiddler

<$link to="MY_TIDDLER"> {{MY_TIDDLER!!caption}} </$link>

{{}} is the notation for a transclusion. see: http://tiddlywiki.com/#Transclusion and   http://tiddlywiki.com/#Transclusion%20in%20WikiText
This is the convenience wikitext for the $transclude widget. ...
 
SOLUTION 2 - this one does not work, WHY ? Instead the caption of MY_TIDDLER it displays {{MY_TIDDLER!!caption}}

[[{{MY_TIDDLER!!caption}}|MY_TIDDLER]]
 
see: http://tiddlywiki.com/#Linking%20in%20WikiText ... the above notation is a "pretty link". As you found out, it treats the first part in the brackets as the "pretty link" text. The transclusion {{}} is not evaluated. Only the text is used. So the [[]] notation is "just" a convenience function for the link widget. It makes it faster and easier to write but for some edge cases it is also limited.

As you found out. For your behaviour you need the link widget, which  gives you maximum flexibility.

To make your desired function easier to read and write, you can cover it into a macro. eg:

\define myLink(tiddler tooltip:"")
  <$link to="""$tiddler$""" tooltip="""$tiddler$$tooltip$""">
    <$transclude tiddler ="""$tiddler$""" field="caption">
      <$view tiddler ="""$tiddler$""" field="title"/>
    </$transclude>
  </$link>
\end


The above function is a bit more generic. It uses the tiddler title, if there is no caption field.


You can use it with: <<myLink noCaption>>   or  <<myLink "tiddler has a caption field">>

lets say the tiddler named noCaption has no caption field. so the title is used
lets say the "tiddler has a caption field" has one so the caption is used. (sorry for the stupid names)

have fun!
mario

Łukasz Hirt

unread,
Aug 12, 2015, 12:50:28 PM8/12/15
to TiddlyWiki
Hi,

Thank you for your answer :) that makes sense, good to know that there are some limitations, well I am aware that there are always some limitations,
but good to learn a new thing.

PS. I understand the code you provided, but I am curious why you enclose parameters with """  """ ?
The only purpose of that I am familair with is to allow Hard line breaks.
Is there any other reason we use it here?

Regards,
Lukasz






PMario

unread,
Aug 12, 2015, 3:55:29 PM8/12/15
to TiddlyWiki
Good question :)
Change to code to:  <$link to="$tiddler$" ...  and try to call the following tiddler name: [[asdf"asdf]]

<<myLink [[asdf"asdf]]>>

or

<<myLink 'asdf"asdf'>>

-mario

Łukasz Hirt

unread,
Aug 13, 2015, 3:31:28 AM8/13/15
to TiddlyWiki
I see :) That makes me more and more aware of what I am doing.

Actually I've got this idea to use single-quotes instead of tripple double-quotes, i.e. I've replaced """$tiddler$""" with '$tiddler$' and it works as well taking less space.
However it will not work if someone wishes to use single-quote, so your method will make everyone happy :)

Thanks once again. I wish you all the best :)

Reply all
Reply to author
Forward
0 new messages