Template:Hidden code: Difference between revisions

From bg3.wiki
Jump to navigation Jump to search
(Created page with "<includeonly><div class="mw-empty-elt"></div></includeonly><noinclude> This template allows having pure code somewhere in a page's source without disturbing the output. For example, variable definitions, or uses of the <code><nowiki>{{#seo:}}</nowiki></code> tag. Consider the following: <pre> First paragraph. {{#lvardef: var1 | Value 1 }} Second paragraph. </pre> The variable definition in the middle will be parsed as an empty paragraph so the result will look like...")
 
(Improve code and explain implementation details in a comment.)
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
<includeonly><div class="mw-empty-elt"></div></includeonly><noinclude>
<includeonly><div class="mw-empty-elt">{{trim | {{{1}}} }}</div><!--
Implementation notes:
* The template parameter {{{1}}} MUST be used, or else its contents won't even be parsed when this template is called.
* The use of trim ensures that the hidden div in the HTML output doesn't contain a crapton of empty paragraphs if you have multiple "paragraphs" of code with empty lines in between.
--></includeonly><noinclude>
This template allows having pure code somewhere in a page's source without disturbing the output. For example, variable definitions, or uses of the <code><nowiki>{{#seo:}}</nowiki></code> tag.
This template allows having pure code somewhere in a page's source without disturbing the output. For example, variable definitions, or uses of the <code><nowiki>{{#seo:}}</nowiki></code> tag.



Latest revision as of 01:26, 7 June 2024

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:

First paragraph.

{{#lvardef: var1 | Value 1 }}

Second paragraph.

The variable definition in the middle will be parsed as an empty paragraph so the result will look like this:

First paragraph.


Second paragraph.

Using this template fixes the problem:

First paragraph.

{{hidden code|
{{#lvardef: var1 | Value 1 }}
}}

Second paragraph.

Result:

First paragraph.

Second paragraph.