I have a template for objects representing documents. I want to transclude the text content of the specified document from the tiddlers for that document as an object. Every document has a tiddler with various information about the document. Most of this information is stored in fields and output into the tiddler from the template, but I could also use variables if necessary. One piece of information that will be stored in either a field or a variable is the title of another tiddler, and that tiddler contains the full text of the document. From the document template, I need a way to transclude a tiddler in each of the child tiddlers based on either a field value or a variable set in those child tiddlers.
I know how to output the value of a field in a child tidder using a template. The obvious first attempt doesn't work:
{{<$view field="content-tiddler" />}}
In the child tiddler, the field
content-tiddler contains the string "DemoContent", which is the exact name of the tiddler I am trying to output inside of the tiddler for this object, which is the same tiddler that is directly transcluding the template tiddler.
Since that does not work, I tried using variables. In both the template tiddler and the child tiddler, I tried setting a variable named contentTiddler with its value as the name of the tiddler that is being transcluded into the child tiddler:
<$set name="contentTiddler" value="DemoContent" />
Then, in the template tiddler:
This does not work, and results in no visible effect. DemoContent is not empty; I copied the Gettysburg Adress into it for testing purposes.
My next attempt involves a macro, and seems to be the closest to success, although it still does not work.
In the template tiddler, I define a macro named transcludeContent with its internal variable named contentTiddler having the default value of "DemoContent":
\define transcludeContent(contentTiddler:"DemoContent")
Hello, world! {{$(contentTiddler)$}}
\end
I am assuming that I could override the value of contentTiddler by overwriting it from within the child tiddlers using
<$set name="contentTiddler" value="AnotherDocumentsText" />, but I haven't bothered to test that yet, as I haven't gotten the macro to work at all, although I did try redefining
contentTiddler from the child tiddler:
<$set name="contentTiddler" value="DemoContent" />
Then, I simply call the macro from inside the template tiddler:
This might be close to success, although it still fails. Currently, it outputs the "Hello world!" that I put in there, and then displays a highlighted red error
Recursive transclusion error in transclude widget. This happens in both the template tiddler and the child tiddler.
What am I missing?