Transclusion and Templates on Tiddler text-body?

174 views
Skip to first unread message

Diego Mesa

unread,
Nov 29, 2017, 3:11:08 PM11/29/17
to TiddlyWiki
I am having some trouble thinking about how to properly setup my research journal. 

What I have now is a new research journal button that creates a tiddler with the following content:

<h3 style="display:inline">[[Weekly Goals|Week WW - YYYY]]</h3> <$appear $state="goals" mode="custom" show="{{$:/.dm/config/appearPlugin!!downarrow}}" hide="{{$:/.dm/config/appearPlugin!!uparrow}}">


{{Week WW - YYYY}}


</$appear>
<hr/>


THE ACTUAL TEXT OF MY RESEARCH DIARY


<hr/><h3 style="display:inline">[[Papers of Interest]]</h3> <$appear
$state="papers" mode="custom" show="{{$:/.dm/config/appearPlugin!!downarrow}}" hide="{{$:/.dm/config/appearPlugin!!uparrow}}">


{{Papers of Interest}}


</$appear>

where WW and YYYY are replaced by the correct week number and year number by wrapping all this in a now macro within the button code.

This has been working fine, but I find myself:
  • frequently changing the look/style of a research journal entry.
  • wanting to learn more about templates and transclusion. 
With this in mind, I want to go about making a "Research Journal Template" that will have all the correct behavior, and somehow having my actual Daily Entries just contain the daily text, but get rendered according to the template. 

I tried making a new template with the above and replacing "THE ACTUAL TEXT OF MY RESEARCH DIARY"  with {{!!text}}, and then making my daily journal with just the following content:

This is a test


{{|MyTemplate}}

Unsurprisingly, this gives a recursive transclusion error in both the template and the daily entry. 

My desired result is:
  • have all tiddlers tagged with both Journal and Research are rendered using the same template I can edit whenever I need to.
  • Have each daily journal entry correctly link to its corresponding weekly goals tiddler. 
    • Not sure how this would be accomplished - perhaps have the template parse the "created" field? I don't want the link to the weekly goals to change with time.
  • The text body of each daily entry contains only relevant (and formatted) daily information. 
    • I don't want to have rendering code in these entries since I want to be able to change that after the fact.
    • I don't want to have to stick everything in a field.
Any and all help would be greatly appreciated! 

Thanks!
Diego

PMario

unread,
Nov 29, 2017, 4:39:51 PM11/29/17
to TiddlyWiki
Hi,

This alone is a recursion already. It creates an infinite loop.

{{!!text}}

You can use any other field name, except of text :)

-m

Diego Mesa

unread,
Nov 29, 2017, 4:45:18 PM11/29/17
to TiddlyWiki
Hey Mario 

Yeah I knew that beforehand, but I just felt that there should be some other way around this. I might type bulleted lists, bold, italics, etc around 1000 words a day for a daily journal. I dont want to just stick that in a tiddler field. 

Im not sure my intention was made clear in the earlier post. I want to type text in the text field of a tiddler, and have it render using a template defined in another tiddler. Is something like that possible?

PMario

unread,
Nov 29, 2017, 5:08:21 PM11/29/17
to TiddlyWiki
Hi Diego,

IMO you can split it into 3 parts.

title: header
tag:
$:/tags/ViewTemplate
list-before: $:/core/ui/ViewTemplate/body

Your stuff above the tiddler text.
<hr>


and

title: footer
tag:
$:/tags/ViewTemplate
list-after: $:/core/ui/ViewTemplate/body

<hr>
Your stuff below the tiddler text.



The problem is, that this is visible for every tiddler.

If you don't want that you can do this for the footer and the header.

<$list filter="[all[current]tag[Journal]]">

title: footer
tag: $:/tags/ViewTemplate
list-after: $:/core/ui/ViewTemplate/body

<hr>
Your stuff below the tiddler text.

</$list>


Which will show the stuff only, if a tiddler is tagged "Journal"


have fun!
mario

Diego Mesa

unread,
Nov 29, 2017, 5:18:57 PM11/29/17
to TiddlyWiki
Hey Mario,

That makes sense - I can conceptually see how to accomplish this by having a header and footer "template" that only gets included in Research Journal entries. 

I was just wondering if something like this is possible via transclusion, or templating. Something like a field: 

template: Research Journal Template

And ever tiddler that has that field will get "stylized" by that template tiddler. 

Mark S.

unread,
Nov 29, 2017, 7:24:15 PM11/29/17
to TiddlyWiki
If your template tiddler is like this:

<$list filter="[all[current]has[template]]">
<$transclude tiddler={{!!template}}/>
</$list>

It will transclude the tiddler stored in the template field of any tiddler that has a 'template' field.

--Mark
Reply all
Reply to author
Forward
0 new messages