Template:Vanchor: Difference between revisions
(code fix; more parameters) |
(→HTML note: rm trivia) |
||
(8 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
<span id="{{{1|}}}"></span>{{#if:{{{2|}}}|<span id="{{{2}}}"></span>}}{{#if:{{{3|}}}|<span id="{{{3}}}"></span>}}{{#if:{{{4|}}}|<span id="{{{4}}}"></span>}}{{#if:{{{5|}}}|<span id="{{{5}}}"></span>}}{{#if:{{{6|}}}|<span id="{{{6}}}"></span>}}{{#if:{{{7|}}}|<span id="{{{7}}}"></span>}}{{#if:{{{8|}}}|<span id="{{{8}}}"></span>}}{{#if:{{{9|}}}|<span id="{{{9}}}"></span>}}{{#if:{{{10|}}}|<span id="{{{10}}}"></span>}}{{{1<noinclude>|Anchor name here</noinclude>}}}<noinclude> | {{#if:{{{1|}}}|<span id="{{{1|}}}"></span>}}{{#if:{{{2|}}}|<span id="{{{2}}}"></span>}}{{#if:{{{3|}}}|<span id="{{{3}}}"></span>}}{{#if:{{{4|}}}|<span id="{{{4}}}"></span>}}{{#if:{{{5|}}}|<span id="{{{5}}}"></span>}}{{#if:{{{6|}}}|<span id="{{{6}}}"></span>}}{{#if:{{{7|}}}|<span id="{{{7}}}"></span>}}{{#if:{{{8|}}}|<span id="{{{8}}}"></span>}}{{#if:{{{9|}}}|<span id="{{{9}}}"></span>}}{{#if:{{{10|}}}|<span id="{{{10}}}"></span>}}{{#if:{{{1|}}}|{{{1<noinclude>|Anchor name here</noinclude>}}}}}<noinclude> | ||
== Documentation == | == Documentation == | ||
Visible anchor: This creates an HTML anchor (in-page link target for an <code>article_name#anchor_name_here</code> link – the part after the <code>#</code>) for the given text, while still displaying the text. | Visible anchor: This creates an HTML anchor (in-page link target for an <code>article_name#anchor_name_here</code> link – the part after the <code>#</code>) for the given text, while still displaying the text. This template is primarily to help lists with anchored entries have cleaner, easier-to-read code. For a version with no visible text, see [[Template:Anchor]]. | ||
This template replaces something like: | |||
:<code><nowiki><span id="Anchor name here"></span>Anchor name here</nowiki></code> | |||
with: | |||
:<code><nowiki>{{vanchor|Anchor name here}}</nowiki></code> | |||
which displays as: | |||
:{{vanchor|Anchor name here}} | |||
(without the indentation; this is an inline template). It can be linked to on this template page as [[Template:Vanchor#Anchor name here]]. The real space and mess savings are when this is used with multiple parameters (see below). | |||
<strong>Important: This text cannot contain markup of any kind, only plain text – no wikimarkup, no templates. If you need to anchor text that has markup, put the markup around the template: | <strong>Important:</strong> This text cannot contain markup of any kind, only plain text – no wikimarkup, no templates. If you need to anchor text that has markup, put the markup around the template: | ||
: <code><nowiki>''{{vanchor|Anchor name here}}''</nowiki></code> | |||
or use a manual <code><nowiki><span id="Anchor name here"></span></nowiki></code> in front of the text (this must be done in particular when the text is an anchor on this page and also a link to something else; you can't have a link inside an anchor or vice versa): | or use a manual <code><nowiki><span id="Anchor name here"></span></nowiki></code> in front of the text (this must be done in particular when the text is an anchor on this page and also a link to something else; you can't have a link inside an anchor or vice versa): | ||
: <code><nowiki><span id="Anchor name here"></span>[[Some other page|Anchor name here again]]</nowiki></code> | |||
Line 42: | Line 47: | ||
=== HTML note === | === HTML note === | ||
This uses | This uses <code><nowiki><span id="..."></span></nowiki></code> format, in front of the target text, rather than <code><nowiki><span id="Anchor name here">Anchor name here</span></nowiki></code> (with the span wrapping the displayed text) because this causes the anchor to mistakenly appear as a clickable but circular link in some old browsers. | ||
[[Category:Templates]] | [[Category:Templates]] | ||
</noinclude> | </noinclude> |
Latest revision as of 09:36, 5 August 2017
Documentation
Visible anchor: This creates an HTML anchor (in-page link target for an article_name#anchor_name_here
link – the part after the #
) for the given text, while still displaying the text. This template is primarily to help lists with anchored entries have cleaner, easier-to-read code. For a version with no visible text, see Template:Anchor.
This template replaces something like:
<span id="Anchor name here"></span>Anchor name here
with:
{{vanchor|Anchor name here}}
which displays as:
- Anchor name here
(without the indentation; this is an inline template). It can be linked to on this template page as Template:Vanchor#Anchor name here. The real space and mess savings are when this is used with multiple parameters (see below).
Important: This text cannot contain markup of any kind, only plain text – no wikimarkup, no templates. If you need to anchor text that has markup, put the markup around the template:
''{{vanchor|Anchor name here}}''
or use a manual <span id="Anchor name here"></span>
in front of the text (this must be done in particular when the text is an anchor on this page and also a link to something else; you can't have a link inside an anchor or vice versa):
<span id="Anchor name here"></span>[[Some other page|Anchor name here again]]
If the text includes an equals sign (=
) anywhere in it, you must use a numbered parameter for the text:
{{vanchor|1=Anchor = name here}}
Also, the text is a literal string. These two are not equivalent:
{{vanchor|Anchor name here}}
{{vanchor| Anchor name here}}
Additional parameters
The template will also create up to 9 additional anchors, for spelling variations, etc. Only the first is displayed. These are given in series or numbered:
{{vanchor|Visible anchor|alternative 1|alternative 2|alternative 3|alternative 4}}
{{vanchor|1=Visible anchor|2=alternative 1|3=alternative 2|4=alternative 3|5=alternative 4}}
HTML note
This uses <span id="..."></span>
format, in front of the target text, rather than <span id="Anchor name here">Anchor name here</span>
(with the span wrapping the displayed text) because this causes the anchor to mistakenly appear as a clickable but circular link in some old browsers.