Transcluding other tiddlers with the template works fine, but when opening the template tiddler itself, I get the red “Recursive Transclusion” error message. I know why it appears and I’m not bothered by it. But I read in [tw5] Query -- How Fatal is the Red message "Recursive transclusion error in transclude widget" that the error can affect performance. What’s the best (i.e. most performant) way to deal with this error?
Just ignore it?
Wrap the transclusion in a list expression that checks if currentTiddler!=templateName?
Add a special tag that tells TiddlyWiki to avoid transclusion?
Make it a system tiddler to hide it as much as possible?
I’m applying the template only to some specific pages, it’s not a viewTemplate.
Wrapping the template in a $list widget got rid of the error, so I guess that’s what I’ll go with, if there are no objections or TiddlyWiki-internal checks that could handle this.
For the future, note that when the tiddler holding your code is displayed as a Story River tiddler (i.e. through the normal View or Edit Templates), this transclude widget is causing ALL of the same code to become translcuded into the <section> element, which starts a recursive loop of dooooooom, as it transcludes itself down into infinity. The $list widget filtering it out when not needed is a good option.
FYI: There was a problem ion tiddlywiki displaying the system tiddler $:/core/ui/PageTemplate and with 5.2.1 the cascade templates remedied this by using the $:/core/ui/ViewTemplate/body/code template for all [prefix[$:/core]] - with some exceptions.
You could create a tiddler tagged $:/tags/ViewTemplateBodyFilter
containing
The TW core already contains some logic, that tests for a field key/value pair: code-body=yes to display the content as code. See https://tiddlywiki.com/prerelease/