@EricShulman’s explanation of how the template parameter works in the tabs Macro is amazing. This gave me the logic I need for my use case - which is an Automotive/Equipment catalog.
My requirements are that the tagged tiddlers:
- Use different templates based on tiddler name
- Some have text and some do not
- Are also viewed outside of the tabs Macro
My Answer:
I opted to create 2 different template tiddlers, 1 for templating the tabs Macro macro and 1 using the tag $:/tags/ViewTemplate.
Used as the template for tabs
title: $:/user/viewtemplate/autoasset-tab
<$tiddler tiddler=<<currentTab>>>
<% if [<currentTiddler>prefix[Information for]] %>
<$transclude $tiddler="AutoAssetInformationTemplate" $mode="block" />
<% elseif [<currentTiddler>prefix[Log for]] %>
<$transclude $tiddler="AutoAssetLogTemplate" $mode="block" />
<% elseif [<currentTiddler>prefix[Parts for]] %>
<$transclude $tiddler="AutoAssetPartCatalogTemplate" $mode="block" />
<% elseif [<currentTiddler>prefix[Tasks for]] %>
<$transclude $tiddler="AutoAssetTaskTemplate" $mode="block" />
<% endif %>
<$transclude $mode="block" />
</$tiddler>
Used as the standard $:/tags/ViewTemplate when viewing the tiddler directly
tags: $:/tags/ViewTemplate
title: $:/user/viewtemplate/autoasset-free
<% if [<currentTiddler>prefix[Information for]] :filter[tags[]tag[Auto Asset]] %>
<$transclude $tiddler="AutoAssetInformationTemplate" $mode="block" />
<% elseif [<currentTiddler>prefix[Log for]] :filter[tags[]tag[Auto Asset]] %>
<$transclude $tiddler="AutoAssetLogTemplate" $mode="block" />
<% elseif [<currentTiddler>prefix[Parts for]] :filter[tags[]tag[Auto Asset]] %>
<$transclude $tiddler="AutoAssetPartCatalogTemplate" $mode="block" />
<% elseif [<currentTiddler>prefix[Tasks for]] :filter[tags[]tag[Auto Asset]] %>
<$transclude $tiddler="AutoAssetTaskTemplate" $mode="block" />
<% endif %>
Notes
-
$transclude macro is used instead of {{}} shorthand which is not affected by blank lines
-
Shortcut Syntax <%if%> is used to work around applying a single template to all of the tiddlers in the tabs Macro macro