<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://battleint.net/index.php?action=history&amp;feed=atom&amp;title=Help%3AMetatemplating</id>
	<title>Help:Metatemplating - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://battleint.net/index.php?action=history&amp;feed=atom&amp;title=Help%3AMetatemplating"/>
	<link rel="alternate" type="text/html" href="https://battleint.net/index.php?title=Help:Metatemplating&amp;action=history"/>
	<updated>2026-10-28T10:19:13Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.44.0</generator>
	<entry>
		<id>https://battleint.net/index.php?title=Help:Metatemplating&amp;diff=172070&amp;oldid=prev</id>
		<title>imported&gt;Deadfire: Creation (as this is needed, and need to come back too as there are templates/help pages that need to be added)</title>
		<link rel="alternate" type="text/html" href="https://battleint.net/index.php?title=Help:Metatemplating&amp;diff=172070&amp;oldid=prev"/>
		<updated>2023-04-30T23:23:49Z</updated>

		<summary type="html">&lt;p&gt;Creation (as this is needed, and need to come back too as there are templates/help pages that need to be added)&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;In the context of Wikipedia, &amp;#039;&amp;#039;&amp;#039;metatemplating&amp;#039;&amp;#039;&amp;#039; involves the use of [[Help:Templates|templates]] as a base to generate other templates.  Some &amp;#039;&amp;#039;&amp;#039;metatemplates&amp;#039;&amp;#039;&amp;#039; work like any other template, and are [[Wikipedia:Transclusion|transcluded]].  Others generate [[Help:Wiki markup|wiki markup]] on-the-fly; these are macro metatemplates, and are [[Wikipedia:Substitution|substituted]].  Metatemplating enables standardized templating, whereby many templates can utilize a common set of components and formats.&lt;br /&gt;
&lt;br /&gt;
Macro metatemplates carry the normal [[Help:Substitution#When to use substitution|disadvantages of substitution]], but they also take advantage of two strong points: substitution is ultimately more efficient, and it allows for the dynamic generation of wiki markup.  This makes it suitable for more intricate systems than those created with transclusion.&lt;br /&gt;
&lt;br /&gt;
== Substitution ==&lt;br /&gt;
&lt;br /&gt;
There are two substitution prefixes: &amp;lt;code&amp;gt;[[H:SUBST|subst:]]&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;[[WP:SAFESUBST|safesubst:]]&amp;lt;/code&amp;gt;.  The difference appears when a template is transcluded instead of substituted; in such a case, &amp;lt;code&amp;gt;subst:&amp;lt;/code&amp;gt; templates will print text as-is, without evaluating, while &amp;lt;code&amp;gt;safesubst:&amp;lt;/code&amp;gt; templates will transclude.&lt;br /&gt;
&lt;br /&gt;
Substitution will reevaluate when the resulting template is included, unlike transclusion.  This makes it useful for macro templating.&lt;br /&gt;
&lt;br /&gt;
=== Bubbling ===&lt;br /&gt;
&lt;br /&gt;
Substitution &amp;#039;&amp;#039;&amp;#039;bubbles&amp;#039;&amp;#039;&amp;#039;:&lt;br /&gt;
&lt;br /&gt;
* If Template A transcludes Template B, and Template B contains &amp;lt;code&amp;gt;safesubst:&amp;lt;/code&amp;gt; includes, &amp;lt;code&amp;gt;safesubst:&amp;lt;/code&amp;gt; will use transclusion.  &amp;lt;code&amp;gt;subst:&amp;lt;/code&amp;gt; would not evaluate.&lt;br /&gt;
* If Template A substitutes Template B, and Template B contains &amp;lt;code&amp;gt;safesubst:&amp;lt;/code&amp;gt; includes, &amp;lt;code&amp;gt;safesubst:&amp;lt;/code&amp;gt; will use substitution.  &amp;lt;code&amp;gt;subst:&amp;lt;/code&amp;gt; would also substitute.&lt;br /&gt;
&lt;br /&gt;
Substitution bubbling continues through a chain of substitutions until a transclude is reached, at which point only transcludes are used.&lt;br /&gt;
&lt;br /&gt;
=== Marking templates meant for substitution ===&lt;br /&gt;
&lt;br /&gt;
Templates meant exclusively for substitution should have {{tl2|subst only}} at the top of their documentation pages.&lt;br /&gt;
&lt;br /&gt;
So that other users can learn to use substituted templates, top-level metatemplates that will appear in normal templates (rather than in other metatemplates) should mark their presence with a comment.  This comment usually goes at the end of the template, and simply contains a link to the substituted template:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color: Gray&amp;quot;&amp;gt;...&amp;lt;/span&amp;gt;&amp;amp;lt;!--&lt;br /&gt;
 --&lt;br /&gt;
 -- Substituted from &amp;lt;nowiki&amp;gt;[[Template:Example]]&amp;lt;/nowiki&amp;gt;.&lt;br /&gt;
 --&lt;br /&gt;
 --&amp;amp;gt;&amp;lt;span style=&amp;quot;color: Gray&amp;quot;&amp;gt;&amp;amp;lt;/includeonly&amp;amp;gt;&amp;amp;lt;noinclude&amp;amp;gt;...&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Delayed evaluation ==&lt;br /&gt;
&lt;br /&gt;
The process of generating text during the first substitution to be evaluated in future transclusions/substitutions is &amp;#039;&amp;#039;&amp;#039;delayed evaluation&amp;#039;&amp;#039;&amp;#039;.  Templates are used to form a chain of substitutions and transclusions.  Delayed evaluation generally requires that all but the last include in the chain be substitution.&lt;br /&gt;
&lt;br /&gt;
Delayed evaluation can be achieved via a template by printing text that will be evaluated as wiki markup by another template.  For example, &amp;amp;lt; and &amp;amp;gt; are printed as-is when they are alone, but together they can be used to form tags.  If a template wanted to form a tag when substituted, it could use the form &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{{|&amp;amp;lt;}}}example/{{{|&amp;amp;gt;}}}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;.  The angled brackets are enclosed in separate wiki markup blocks, so they do not join.  Since a &amp;quot;blank&amp;quot; parameter name is always undefined, the angled brackets will always be printed as the fallback values, and the resulting text will be &amp;lt;code&amp;gt;&amp;amp;lt;example/&amp;amp;gt;&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== HTML entities ===&lt;br /&gt;
&lt;br /&gt;
(X)HTML entities such as &amp;lt;code&amp;gt;&amp;amp;amp;#124;&amp;lt;/code&amp;gt; (&amp;amp;#124;) will not be translated during substitution, so they will never evaluate.  They are only useful for preventing text from being evaluated at all.&lt;br /&gt;
&lt;br /&gt;
=== Undefined parameter defaults ===&lt;br /&gt;
&lt;br /&gt;
Parameters can have default values for when they are undefined: &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{{parameter-name|default-value}}}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
There is one parameter that always defaults: the unnamed parameter.  When the parameter name is omitted, the default value will always print: &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{{|always-prints}}}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Undefined parameter defaults are useful for escaping text that would otherwise be evaluated.  For example, to break up a tag that should print as text:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;{{{|&amp;amp;lt;}}}example/{{{|&amp;amp;gt;}}}&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After the first substitution:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&amp;amp;lt;example/&amp;amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Further includes would evaluate the tag.&lt;br /&gt;
&lt;br /&gt;
Parameters are processed prior to substitution, so they can also be used for conditional substitution.  For example, to only substitute when the &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;nosubst&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; parameter is undefined:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;{{{{{nosubst|subst:}}}example}}&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Tags ===&lt;br /&gt;
&lt;br /&gt;
Curly braces delimit angled brackets to prevent the formation of a tag, so the easiest way to escape tags is with [[#Undefined_parameter_defaults|undefined parameter defaults]].  This does not have the overhead of a template call.  Example:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;{{{|&amp;lt;}}}example/{{{|&amp;gt;}}}&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After the first substitution:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&amp;amp;lt;example/&amp;amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Tags can be escaped much like [[#Braces|braces]].  Alternatively, the {{tl2|lessthan}} template can be used, though it is less efficient.  Producing the same result as the previous example:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&amp;amp;lt;includeonly&amp;amp;gt;&amp;amp;lt;&amp;amp;lt;/includeonly&amp;amp;gt;example/&amp;amp;lt;includeonly&amp;amp;gt;&amp;amp;gt;&amp;amp;lt;/includeonly&amp;amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;{{lessthan}}example/&amp;amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is usually only necessary for &amp;lt;code&amp;gt;includeonly&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;noinclude&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;nowiki&amp;lt;/code&amp;gt; tags.  In such a case, it is preferable to use the {{tl2|includeonly}}, {{tl2|noinclude}}, and {{tl2|nowiki}} templates, respectively:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;{{includeonly|{{example}}}}&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After the first substitution:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&amp;amp;lt;includeonly&amp;amp;gt;{{example}}&amp;amp;lt;/includeonly&amp;amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Further transclusions and substitutions:&lt;br /&gt;
&lt;br /&gt;
{{example}}{{-}}&lt;br /&gt;
&lt;br /&gt;
=== Braces ===&lt;br /&gt;
&lt;br /&gt;
Curly braces, if separated by &amp;lt;code&amp;gt;includeonly&amp;lt;/code&amp;gt; tags, will print as-is.  Note that these three tags (includeonly, noinclude, and nowiki) cannot be nested within themselves, so this trick can only be used in top-level code. &amp;lt;code&amp;gt;nowiki&amp;lt;/code&amp;gt; tags won&amp;#039;t work, as they won&amp;#039;t be removed by the substitution process.  There are several possible combinations:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&amp;amp;lt;includeonly&amp;amp;gt;{{&amp;amp;lt;/includeonly&amp;amp;gt;example&amp;amp;lt;includeonly&amp;amp;gt;}}&amp;amp;lt;/includeonly&amp;amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;{{&amp;amp;lt;includeonly&amp;amp;gt;example&amp;amp;lt;/includeonly&amp;amp;gt;}}&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;{{&amp;amp;lt;includeonly/&amp;amp;gt;example&amp;amp;lt;includeonly/&amp;amp;gt;}}&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After the first substitution, each produces:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;{{example}}&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Further transclusions and substitutions:&lt;br /&gt;
&lt;br /&gt;
{{example}}{{-}}&lt;br /&gt;
&lt;br /&gt;
A less efficient method is to use metatemplates that print braces.  Unlike &amp;lt;code&amp;gt;includeonly&amp;lt;/code&amp;gt; tag separation, metatemplates will work when inside another wiki markup block, such as within an argument to another template.  There are general-purpose metatemplates using parentheses in place of braces.  This will produce a result identical to that of the previous example:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;{{((}}example{{))}}&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Other metatemplates for producing similar combinations:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Please use tl2 here for consistency. --&amp;gt;&lt;br /&gt;
* {{tl2|(}} produces &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
* {{tl2|)}} produces &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
* {{tl2|((}} produces &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
* {{tl2|))}} produces &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;}}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
* {{tl2|(((}} produces &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{{&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
* {{tl2|)))}} produces &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;}}}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
See also {{cl|Template namespace templates}}.&lt;br /&gt;
&lt;br /&gt;
The template {{tl|braces}} can produce, for example, the following:&lt;br /&gt;
&lt;br /&gt;
: {{tlx|braces|Templatename|item1|item2|...|item8}}{{nbsp|2}}→{{nbsp|2}}{{braces|Templatename|item1|item2|...|item8}}&lt;br /&gt;
: {{tlx|braces|code{{=}}on|Templatename|item1|item2|...|item8}}{{nbsp|2}}→{{nbsp|2}}{{braces|code=on|Templatename|item1|item2|...|item8}}&lt;br /&gt;
&lt;br /&gt;
For more details, see [[Template:Braces]].&lt;br /&gt;
&lt;br /&gt;
=== Other wiki markup symbols ===&lt;br /&gt;
These characters and sequences often need to be escaped when writing a template, but should be evaluated by future templates.  Also see {{section link|#Braces}} above.  Line breaks are shown by {{color|green|\n}}.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Please use tl2 here for consistency. --&amp;gt;&lt;br /&gt;
* {{tl2|!}} produces &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;|&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
* {{tl2|!!}} produces &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;||&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
* {{tl2|!(}} produces &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;[&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
* {{tl2|!)}} produces &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;]&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
* {{tl2|!((}} produces &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;[[&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
* {{tl2|!))}} produces &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;]]&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
* {{tl2|1==}} produces &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;=&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
* {{tl2|!-}} produces &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;|-&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
* {{tl2|-!-}} produces &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;&amp;amp;amp;nbsp;&amp;lt;/nowiki&amp;gt;{{color|green|\n\n}}&amp;lt;nowiki&amp;gt;|-&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
* {{tl2|s-start}} produces the start of a centered table; see the [//en.wikipedia.org/w/index.php?title=Template:s-start&amp;amp;action=edit s-start source code] for details.&lt;br /&gt;
* {{tl2|end}} produces &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;|}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
* {{tl2|lessthan}} produces &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;&amp;amp;lt;&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Help]]&lt;/div&gt;</summary>
		<author><name>imported&gt;Deadfire</name></author>
	</entry>
</feed>