Template:Adr/doc

From WikiAlpha
Jump to: navigation, search


Purpose

save contributors from typing and make editing easier by shortening long links by auto-generating pretty-text formation. The template automatically presents the short form of 'qualified titles' where the main term is modified by a term after a comma (i.e. an address form of a data record. This (the eponymous ADRess) format saves a lot of typing in linking place and history articles, such as:

WhyNotHere County, Nebraska or
Mount Pisgah, Carbon County, Pennsylvania and alternative syntax allows pretty link presentations of page titles with parenthesizes like 'Beaver Creek (Pennsylvania)'
these examples respectively present a link with a simpler but oft needed desirable display form as: 'WhyNotHere County', 'Mount Pisgah' and 'Beaver Creek'.
Note on templates
Wikimarkup language Templates take parameters differentiated by either names or position. This template uses 'positional parameters' or 'Pass Arguments'; this means where a term is given is important, as you will see, skipping a term is a way of passing over its definition, yet using the argument that follows.

Usage

  • By convention, Arg0 is the name of the template, so in this case, 'Adr' for the 'Address' template.
  • by purpose, Arg1 will be some common name or term, which has been used in multiple contexts and forms the key part of the desired link, so needs set off in the data mapping world of digital computers. Hence it is the term to be modified, and almost always the text of what we want first in the 'pretty link'.


So active mode controls are:

  • Arg2 when given is assumed to be comma separated text, without the comma or space.
These format & display as if a simple Arg1 link. {{ adr|Arg1|Arg2 }} → will generate → 'Arg1' as a link
So...
  • Instead of literal [[ Pittsburgh, PA ]] given as: {{adr|Pittsburgh|PA}} → will generate → [[Pittsburgh]] but as a link.
  • Instead of literal [[Centerville, Washington County, Pennsylvania]] given as: </code>{{adr|Centerville|Washington County, Pennsylvania}}</code> → will generate → Centerville.


  • Arg3 or p is for handling the 'parenthesis forms' so beloved in our technical pages.
These format & display as if a simple Arg1 link, and are most often used without any Arg2 parameter.*
Thus, instead of [[Beaver Creek (Pennsylvania)]] given as: {{adr|Beaver Creek||Pennsylvania}} → the template saves typing and article text space when it generates → [[Beaver Creek (Pennsylvania)|Beaver Creek]] Beaver Creek.


Similarly, for two words separated by a space, where the desire and need is to display the keyword without the classification:

  • Arg4 causes both Arg2 and Arg3 to be ignored, forming a link as the second word following a space, but creating a single word 'display link' for those article page titles using a space separated pair of words needing a link, when the context provided by the second is clear.
Instead of Erie people {{adr|Erie|||people}} → will generate → [[Erie people|Erie]].
  • d is display this form for overiding long names like list of railroads in... and making them display simply. d=phrase, when defined, always displays as the title of the link formation set by the other parameters.

Examples of Adr uses

Example 1, comma forms
{{Adr|Beaver Creek|Carbon County, Pennsylvania}} becomes Beaver Creek as if formed by the clutter making long winded:
[[Beaver Creek, Carbon County, Pennsylvania |Beaver Creek]]
  • The Adr template has a slightly different syntax when handling parenthesized typing-aids. When given a null as the second parameter, it parenthesizes the next (so third, the Arg3) argument (since second, Arg2 was null data) instead of politely putting it behind a comma.
Other examples of Adr typing aid template
{{Adr|Beaver Creek||Pennsylvania}} and {{adr|saddle||landform}} form polite type-adjusted parenthesized links.
Please do note the double pipe characters '||' sandwiched in the middle above! The first forms a link to a disambig page title 'Beaver Creek' and the second to the article about the walk-able part of a mountain pass, the saddle as if [[saddle (landform)|saddle]] were used.


Guts

{{#if:{{{4|}}}|[[{{{1}}} {{{4}}}|{{{d|{{{1}}}}}}]]<!--
  else --->|{{#if:{{{p|{{{3|}}}}}}<!--
    then --->|[[{{{1|}}} ({{{p|{{{3|}}}}}}) |{{{d|{{{1|}}}}}}]]<!--
    else --->|[[{{{1|Lehigh Township}}}, {{{2|Pennsylvania}}}|{{{d|{{{1|}}}}}}]]<!--
        --->}}<!--
--->}}


*   For those who don't parse template code, if one gives both Arg2 and Arg3, Arg3 wins! The Arg3 mode with a double pipe after the 'Arg0 template name' term ('Adr') then produces a link as if the Arg2 term were modified by '(Arg3)'.