Automatically apply a template to all transclusions?

Is it possible to automatically apply my custom template to all the transclusions without changing the wikitext?

So that I do not have to remember to apply my template all my future transclusions {{some||my-template}} and to update my past transclusions.

Related to Show transclusions in specific format

There may be a way to hack the default transclusion method but this would then apply to various core template functions and break them.

  • I think it would be unwise
  • Surely there will be cases where you do not want this default?

However if the problem is “So that I do not have to remember to apply my template all my future transclusions” there are other ways to simplify this.

  • For example in the editor toolbar there is a button to wrap some text in {{some}} you could make one to wrap the text in `{{some||my-template}}’
  • There are other methods available including
    • using macros <<my-template "some">> that does the same thing.
    • have the transclusion more than one deep.

To address existing transclusions you may be able to build a batch process to do this, however you must not apply this to other core and plugin transclusions.

  • In this kind of activity it is good to have the relink plugin as a helper.

You can use the stamp-tool in the edit toolbar buttons and define a new snippet. The stamp dropdown shows “Add your own” as the last element.

I’m not sure that I would recommend it as an approach, but I think it would be possible to do that with the changes in https://github.com/Jermolene/TiddlyWiki5/pull/6666.

The idea would be to redefine the transclude widget using a custom widget and then within the widget to re-issue the transclusion using the genesis widget with a default value applied to the template parameter. See the visible transclusion example for the general approach:

These changes could be applied locally by packaging them as a custom widget:

<$$set-default-transclusion-template template="foobar">
{{Boo}} is now treated as if it was {{Boo||foobar}}
</$$set-default-transclusion-template>
1 Like