GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||
GeezerVison is showing en.wikipedia.org — Help:Metatemplating - Wikipedia
In the context of Wikipedia, metatemplating involves the use of templates as a base to generate other templates. Some metatemplates work like any other template, and are transcluded. Others generate wiki markup on-the-fly; these are macro metatemplates, and are substituted. Metatemplating enables standardized templating, whereby many templates can utilize a common set of components and formats. Macro metatemplates carry the normal 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. SubstitutionThere are two substitution prefixes: Substitution will reevaluate when the resulting template is included, unlike transclusion. This makes it useful for macro templating. BubblingSubstitution bubbles. The prefix
Substitution bubbling continues through a chain of substitutions until a transclusion is reached, at which point only transclusions are used. Marking templates meant for substitutionTemplates meant exclusively for substitution should have 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: ...<!-- -- -- Substituted from [[Template:Example]]. -- --></includeonly><noinclude>... Delayed evaluationThe process of generating text during the first substitution to be evaluated in future transclusions/substitutions is delayed evaluation. 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. Delayed evaluation can be achieved via a template by printing text that will be evaluated as wiki markup by another template. For example, < and > 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 HTML entities(X)HTML entities such as Undefined parameter defaultsParameters can have default values for when they are undefined: 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: {{{|<}}}example/{{{|>}}}
After the first substitution: <example/>
Further includes would evaluate the tag. Parameters are processed prior to substitution, so they can also be used for conditional substitution. For example, to only substitute when the {{{{{nosubst|subst:}}}example}}
TagsCurly braces delimit angled brackets to prevent the formation of a tag, so the easiest way to escape tags is with undefined parameter defaults. This does not have the overhead of a template call. Example: {{{|<}}}example/{{{|>}}}
After the first substitution: <example/>
Tags can be escaped much like braces. Alternatively, the <includeonly><</includeonly>example/<includeonly>></includeonly> {{lessthan}}example/> This is usually only necessary for {{includeonly|{{example}}}}
After the first substitution: <includeonly>{{example}}</includeonly>
Further transclusions and substitutions:
BracesCurly braces, if separated by <includeonly>{{</includeonly>example<includeonly>}}</includeonly> {{<includeonly>example</includeonly>}} {{<includeonly/>example<includeonly/>}} After the first substitution, each produces: {{example}}
Further transclusions and substitutions:
A less efficient method is to use metatemplates that print braces. Unlike {{((}}example{{))}}
Other metatemplates for producing similar combinations:
See also Category:Template namespace templates. The template {{braces}} can produce, for example, the following:
For more details, see Template:Braces. Other wiki markup symbolsThese characters and sequences often need to be escaped when writing a template, but should be evaluated by future templates. Also see § Braces above. Line breaks are shown by \n.
See also
| |||||||
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |