I'm not sure how you're activating your template.
If you have a template tiddler, tagged $:/tags/ViewTemplate, with the
following content:
<$list filter="[all[current]has[content-tiddler]]">
<$transclude tiddler={{!!content-tiddler}}/>
</$list>
Then any tiddler with content-tiddler field will include content from the
tiddler referenced in the content-tiddler field.
The outer list filter is to prevent the template from being activated for
other tiddlers that don't have the content-tiddler field.
Good luck!
On Thursday, November 28, 2019 at 3:24:55 AM UTC-8, Paul Lee wrote:
>
> 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:
> {{<contentTiddler>}}
>
> 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:
>
> <<transcludeContent>>
>
> 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?
>
--
You received this message because you are subscribed to the Google Groups
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/tiddlywiki/15decf56-ced7-40ef-b0aa-d34770eba931%40googlegroups.com.