My (MarcinK's) Search For The Ultimate Wiki Template Macro

This page outlines my findings as I am searching for a what I believe to be the ultimate wiki template macro

Features of Ultimate Wiki Template Macro

What am I looking for?

  1. Works with Trac 1.0

  1. The ability to store portions of page content in another wiki page, and include them in current page, with them being rendered in current page's context. This is similar to the IncludMacro, but IncludMacro renders the template content in the context of the template wiki page.
  1. The ability to pass named parameters to the macro call (i.e. ParamName=param_value, and have the macro replace every instance of something like {{ParamName}} with the passed param_value). This is very similar to (...fill in macro names...), but the mentioned macros use a sequence of parameters and replace {{1}}, {{2}}, etc., instead of named parameters. Desired use example: [[UltimateTemplateExpand(TemplateName,ParamOne=value_one,ParamTwo=value two,ParamThree=value_three)]]. This also needs a mechanism of 'escaping' markers so that they would not be expanded.
  1. The ability to have some of the environment content available for auto expansion in the macro. For example, being able to insert the wiki page's name into the template as it is being expanded. This could be done in a number of possible ways, some of which are:

a) Being able to specify special param_value in the macro invocation syntax, for example: [[UltimateTemplateExpand(TemplateeName,PageName=&env.PageName)]]

b) Being able to directly reference an environment variable in the template using something like {{&env.PageName}}. However, I see this as less desirable as it would require more compute-intensive processing, where all patterns of text in double curly braces would have to be processed. Previous option still allows global replace of only known patterns.

  1. The ability to specify page !global variables for the template expansion. This means that starting a wiki page with something like [[UltimateTemplateVars(VarName=value,VarName2=value2)]] would expand "VarName" and "VarName2" in all subsequent calls to UltimateTemplateExpand, but in the current page only.


Here are my notes on what I found, what works, and what does not. I also posted a related question on Stack Overflow.


TODO add finding RE IncludeMacro


TODO add findings RE WikiIncludePlugin

TracWikiTemplates Plugin

TODO add finidngs RE TracWikiTemplates Plugin


Thanks to hasienda on Stack Overflow for pointing out the PageVariableMacro.

What Works:

  • This is an example of having page wide variables (requirement 5)

What Does Not Work:

  • This is an older macro that is reported to not work with Trac 0.11, breaking requirement 1.


Published to trac-hacks on 2015-01-19.

This is a nice and simple macro.

What Works:

  • Allows expansion of a template and works in Trac 1.0 (requirement 1 and at least part of 2 met)

What Does Not Work:

  • Uses sequenced (numbered) placeholders instead of named ones (fails requirement 3)

What's Pending Testing:

  • If the template page is rendered (Wiki interpreted) in the context of the template page or the page calling it
Last modified 5 years ago Last modified on Feb 12, 2017, 9:23:50 AM