How to make the templates which can show it's own info not just title?

69 views
Skip to first unread message

imleg...@gmail.com

unread,
Sep 14, 2021, 5:14:04 AMSep 14
to TiddlyWiki
I read the page https://tiddlywiki.com/static/Transclusion%2520with%2520Templates.html

which tell me how to make the template of the Transclusion Which I think is great.

But I don't know how to make the template to show it's own info.

If I use the "{{}}" in the template tiddler I will get a recursive error. 

{{!!title}} works fine but I rarely use it. 

This will get a recursive error.
```
@@background-color:yellow;
{{}}
@@
```

imleg...@gmail.com

unread,
Sep 14, 2021, 6:20:38 AMSep 14
to TiddlyWiki
And one more question how to set a template as the default setting of the Transclusion, since I use the template so much it will be boring if I have to set the template manually everytime

PMario

unread,
Sep 14, 2021, 7:39:06 AMSep 14
to TiddlyWiki
Hi

Try something like this:

\define test()
This is a test
\end

<<test>>

<pre><code><$view ></code><pre>

imleg...@gmail.com

unread,
Sep 14, 2021, 11:45:02 AMSep 14
to TiddlyWiki
Sorry I can't get what your meaning, I copied your code to my tw, nothing happened, 
what I want is a template which can change the background color of the  Transclusion. 


which give a example 
```
@@background-color:yellow;
{{!!title}}
@@
```

{!!title} will show the title literaly. But I need the body of the tiddler not title how to set it?

I don't know the meaning of this code. It seems not like a template

\define test()
This is a test
\end

<<test>>

<pre><code><$view ></code><pre>




Mark S.

unread,
Sep 14, 2021, 1:43:03 PMSep 14
to TiddlyWiki
The {{thing}} is the transclusion. 

But it sounds like you want to change the color of a tiddler based on some criteria. If your criteria is a tag, for instance, than the easy way to do this is with a stylesheet.

For instance, say you have tiddlers tagged "Yellow".

Then make a tiddler and tag it $:/tags/Stylesheet and put this content in it:

[data-tags*="Yellow"].tc-tiddler-frame  {
background-color: yellow ;
}

Save the tiddler.

Now all your tiddlers tagged "Yellow" will have a yellow frame. This is the entire frame, and not just the body which is just the text part. The actual body is identified as .tc-tiddler-body 

In general, real templates are used to add display functionality to tiddlers. They don't change the existing way the text is presented. There are many things that can be accomplished just with stylesheets and CSS.

HTH

PMario

unread,
Sep 14, 2021, 2:52:08 PMSep 14
to TiddlyWiki
On Tuesday, September 14, 2021 at 5:45:02 PM UTC+2 imleg...@gmail.com wrote:
Sorry I can't get what your meaning, I copied your code to my tw, nothing happened, 

The topic of the OP is: How to make the templates which can show it's own info not just title? 

My example shows, how you can create some wikitext, that allows you to show the content of the tiddler, without creating a recursion error.
 
what I want is a template which can change the background color of the  Transclusion. 

That's a completely different question.

Transclusions don't have a wrapper element in the rendered output. So there is nothing you can style.
The example you referred to, doesn't change the color of the transclusion. It creates a new element with a yellow background and then transcluded the title of a tiddler. It has nothing to do with coloring a transclusion.

You can import the attached file and play with it.

It contains a tiddler: tr .. which contains the template

a ... contains some text
tr-style ... contains the stylesheet with the background color setting.

The transclusion has to be called with {{tiddler name||tr}} ... There is _no_ way around this.

have fun!
-mario

style-a-transclusion.json

imleg...@gmail.com

unread,
Sep 15, 2021, 12:45:02 AMSep 15
to TiddlyWiki
Can't thank you more. I will make the question more clearly next time.
Reply all
Reply to author
Forward
0 new messages