Template:Anchor/doc: Difference between revisions

no edit summary
m (1 revision imported: Import from https://sims.wikia.com)
No edit summary
 
(4 intermediate revisions by the same user not shown)
Line 1:
{{Lua|
The template <nowiki>{{</nowiki>[[{{ns:Template}}:{{BASEPAGENAME}}|{{lc:{{BASEPAGENAME}}}}]]<nowiki>}}</nowiki> inserts one or more [[Wikipedia:HTML element#Anchor|HTML anchor]]s in a page. Those locations can then be linked to using <code><nowiki>[[#link|...]]</nowiki></code> syntax. {{#ifeq:{{BASEPAGENAME}}|Visible anchor|&nbsp;Unlike {{tl|Anchor}}, the first parameter will be visible text on the page. See the "[[#Usage details|Usage details]]" section for an example.|}}
* [[Module:Anchor]]}}
<includeonly>[[Category:General wiki templates|{{PAGENAME}}]]</includeonly><noinclude>[[Category:Template documentation|{{PAGENAME}}]]</noinclude>
==Description==
This creates one or more HTML anchors so you can jump to where this template appears with <code><nowiki>[[</nowiki></code>''pagename''<code>#</code>''anchorname''<code><nowiki>]]</nowiki></code>. The result of the template should not be visible on the page.
 
==Syntax==
{{Wikipedia}}
Type <code>{{t|Anchor|anchorname1|anchorname2|anchorname3|...}}</code> somewhere.
 
==Example==
:<code><nowiki>{{Anchor|jumphere}}</nowiki></code> &rarr; {{Anchor|jumphere}}
:.
:.
:.
:.
:.
:.
:.
:.
:.
:.
:.
:[[#jumphere|Click me to jump to anchor]].
 
==Limitations==
{|class="wikitable" style="float:right"
!Character
![[wikipedia:Character entity reference|Code]]
!Template
!Meaning
|-
|"
|<code>&amp;quot;</code> <br /><code>&amp;#34;</code>
|N/A
|(double)&nbsp;[[wikipedia:quotation mark|quotation mark]]
|-
|#
|<code>&amp;#35;</code>
|N/A
|[[wikipedia:Number sign|hash]]
|-
|&#124;
|<code>&amp;#124;</code>
|{{tl|!}}
|[[wikipedia:Vertical bar|pipe]]
|-
|&#61;
|<code>&amp;#61;</code>
|{{tl|{{=}}}}
|[[wikipedia:Equals sign|equals]]
|}
The characters listed on the right will cause problems with the template and should not be used. If you need to use them, replace them with the HTML character code provided. For example, if you need to use quotation marks, substitute them with <code>&amp;quot;</code> or <code>&amp;#34;</code>.
 
Alternatively, if you need to use pipe (|) or equal sign (=) characters, you may use the {{tl|!}} and {{tl|{{=}}}} templates, respectively, to use them.
 
== Use in tables ==
Anchors may be used within tables, subject to certain restrictions. The {{tlx|anchor}} template may be used in the caption and cells of a table, but not those portions of a table that are outside the caption and cells. It is used on the table's caption thus:<source enclose=div lang=text>|+ {{anchor|FooX}} A table caption</source> and the following forms of cell are valid:
 
<source enclose=div lang=text>!{{anchor|Foo1}} A header cell
!style="background:white;" |{{anchor|Foo2}} A header cell with styling
|{{anchor|Foo3}} A data cell
|rowspan=2 |{{anchor|Foo4}} A data cell spanning two rows</source>
 
You need to ensure that the {{tlx|anchor}} is not in that portion of the markup intended for the classes, styles etc. Thus, {{tlx|anchor}} cannot be placed anywhere on lines that begin with <code><nowiki>{|</nowiki></code> (start of table) or <code><nowiki>|-</nowiki></code> (new row), and the following forms of cell are not valid:
 
<source enclose=div lang=text>!{{anchor|Foo1}} |A header cell
!style="background:white;" {{anchor|Foo2}} |A header cell with styling
|{{anchor|Foo3}} |A data cell
|rowspan=2 {{anchor|Foo4}} |A data cell spanning two rows</source>
 
If it is necessary for an anchor to be in any of these positions, a different technique is used—the <code>id=</code> attribute. This is placed in that portion of the markup where the classes, styles etc. may be used, as follows:
 
<source enclose=div lang=text>{| id=FooX class=wikitable
|- id=FooY
!id=Foo1 |A header cell
!style="background:white;" id=Foo2 |A header cell with styling
|id=Foo3 |A data cell
|rowspan=2 id=Foo4 |A data cell spanning two rows</source>
 
The <code>id=</code> attribute may appear before, between or after any other attributes that may be present, but only one <code>id=</code> attribute may be used in each of these areas.
 
==Credits==
The template's Lua code and parts of its documentation were taken from the [[w:en:Template:Anchor|English Wikipedia]].
 
A non-Lua version of the template was formerly used <span class="plainlinks">[https://www.thesimswiki.com/w/index.php?title=Template:Anchor&oldid=1644 here]</span>. That code was taken from the [[wikia:w:c:templates:Template:Anchor|Templates Wiki]] on Wikia.
 
==TemplateData==
{{TemplateData header}}
<templatedata>
{
"description": "This template inserts one or more HTML anchors in a page, which can then be linked to using [[#location|...]] syntax, or by going to https://www.thesimswiki.com/Name_of_page#Anchor_title. This is useful when you need to link to very specific parts in an article.",
"params": {
"1": {
"label": "First anchor",
"description": "First anchor value.",
"type": "string",
"required": true
},
"2": {
"label": "Second anchor",
"description": "Second anchor value.",
"type": "string",
"required": false
},
"3": {
"label": "Third anchor",
"description": "Third anchor value.",
"type": "string",
"required": false
},
"4": {
"label": "Fourth anchor",
"description": "Fourth anchor value.",
"type": "string",
"required": false
},
"5": {
"label": "Fifth anchor",
"description": "Fifth anchor value.",
"type": "string"
},
"6": {
"label": "Sixth anchor",
"description": "Sixth anchor value.",
"type": "string"
},
"7": {
"label": "Seventh anchor",
"description": "Seventh anchor value.",
"type": "string"
},
"8": {
"label": "Eight anchor",
"description": "Eight anchor value.",
"type": "string"
},
"9": {
"label": "Ninth anchor",
"description": "Ninth anchor value.",
"type": "string"
},
"10": {
"label": "Tenth anchor",
"description": "Tenth anchor value.",
"type": "string"
}
}
}
</templatedata>
 
<includeonly>[[Category:General wiki templates|{{PAGENAME}}]]</includeonly>
<noinclude>[[Category:Template documentation|{{PAGENAME}}]]</noinclude>