Template:Hidden code
Jump to navigation
Jump to search
Template documentation
This template allows having pure code somewhere in a page's source without disturbing the output. For example, variable definitions, or uses of the {{#seo:}} tag.
Consider the following example; the variable definition in the middle is parsed as an empty paragraph:
Markup
First paragraph.
{{#lvardef: x | Blah blah }}
Second paragraph: {{#lvar:x}}
Renders asFirst paragraph.
Second paragraph: Blah blah
Using this template fixes the problem:
Markup
First paragraph.
{{hidden code|
{{#lvardef: x | Blah blah }}
}}
Second paragraph: {{#lvar:x}}
Renders asFirst paragraph.
Second paragraph: Blah blah
Notes
- Using this adds a tiny amount of overhead: About 70 μs (microseconds) according to a rough test. This can still add up in the case of templates that are called all over the place, such as Template:Character link, Template:Item icon, Template:Icon link and so on. As a case study, Act One/Inspiration was invoking this template about 1500 times when it was used the implementation of both Template:Character link and Template:Icon text (which is indirectly used by Template:Character link). At 70 μs per call, that adds about 100 ms or 0.1 second to the parsing of the page. For this reason, "high usage volume" templates avoid using this at the cost of slightly uglier code.
- This template would normally add
<span class="bg3wiki-hidden-code"></span>to the HTML output for the page. (Possibly wrapped in a<p></p>element.) That's benign, since empty text has a height of zero. However, for additional HTML tidiness, some custom code in the wiki's configuration strips that out completely.