Difference between revisions of "Template:Cite IETF/makelink"

From blackwiki
Jump to navigation Jump to search
imported>Tothwolf
(Try #ifeq again)
imported>Tothwolf
(Refactor)
Line 1: Line 1:
{{#if:{{{Url|}}}|{{{Url}}}{{#if:{{{Anchor|}}}|{{{Anchor}}}}}|{{
+
{{
  #if:{{{Rfc|}}}{{{Std|}}}{{{Bcp|}}}{{{Fyi|}}}{{{Draft|}}}|{{
+
  #if:{{{Url|}}}
    #ifeq:{{yesno|{{{Autolink|}}}|blank=yes}}|yes|http://tools.ietf.org{{
+
  |{{{Url}}}{{
      #if:{{{Rfc|}}}|/html/rfc{{{Rfc}}}|{{
+
    #if:{{{Anchor|}}}
        #if:{{{Std|}}}|/rfcmarkup?doc=std{{{Std}}}|{{
+
    |{{{Anchor}}}
          #if:{{{Bcp|}}}|/html/bcp{{{Bcp}}}|{{
+
  }}
            #if:{{{Fyi|}}}|/rfcmarkup?doc=fyi{{{Fyi}}}|{{
+
  |{{
              #if:{{{Draft|}}}|/html/{{{Draft}}}
+
    #if:{{{Rfc|}}}{{{Std|}}}{{{Bcp|}}}{{{Fyi|}}}{{{Draft|}}}
             }}
+
    |{{
 +
        #ifeq:{{yesno|{{{Autolink|}}}|blank=yes}}|yes
 +
        |http://tools.ietf.org{{
 +
          #if:{{{Rfc|}}}
 +
          |/html/rfc{{{Rfc}}}
 +
          |{{
 +
            #if:{{{Std|}}}
 +
            |/rfcmarkup?doc=std{{{Std}}}
 +
            |{{
 +
                #if:{{{Bcp|}}}
 +
                |/html/bcp{{{Bcp}}}
 +
                |{{
 +
                  #if:{{{Fyi|}}}
 +
                  |/rfcmarkup?doc=fyi{{{Fyi}}}
 +
                  |{{
 +
                      #if:{{{Draft|}}}
 +
                      |/html/{{{Draft}}}
 +
                    }}
 +
                }}
 +
              }}
 +
          }}
 +
        }}{{
 +
            #if:{{{Anchor|}}}
 +
             |{{{Anchor}}}
 
           }}
 
           }}
        }}
 
 
       }}
 
       }}
    }}{{#if:{{{Anchor|}}}|{{{Anchor}}}}}
+
  }}
  }}
+
}}<noinclude>{{documentation}}</noinclude>
}}}}<noinclude>{{documentation}}</noinclude>
 

Revision as of 20:08, 28 October 2009

Template documentation[view] [edit] [history] [purge]

This template is a "subroutine" of {{Cite IETF}} used for conditionally creating links to https://tools.ietf.org/ for different types of documents.

It is invoked as:

{{Cite IETF/makelink
| Url = <value of |url= or |archiveurl= parameters>
| Anchor = <section or page anchor generated from the value of the |section= or |page= parameters>
| Autolink = <value of |autolink= parameter>
| Rfc = <value of |rfc= parameter>
| Std = <value of |std= parameter>
| Bcp = <value of |bcp= parameter>
| Fyi = <value of |fyi= parameter>
| Draft = <value of |draft= parameter>
| Ien = <value of |ien= parameter>
| Rtr = <value of |rtr= parameter>
}}

It uses the following algorithm:

  1. If the |Url= parameter is given the template will simply display that value along with an optional anchor generated from |Anchor= appended.
  2. If the |Url= parameter is not given, if any of |Rfc=, |Std=, |Bcp=, |Fyi=, |Draft=, |Ien=, or |Rtr= parameters are given, and the |Autolink= parameter evaluates to anything other than no then the template will generate a url using one of the document type identifiers given.
  3. The template will give priority to the first of the parameters: |Rfc=, |Std=, |Bcp=, |Fyi=, |Draft=, |Ien=, or |Rtr= in this order and create a link using the first matching parameter.
  4. If the |Anchor= parameter is given, it will be appended to the generated url.

This "subroutine" is designed for {{Cite IETF}} and makes assumptions that may not be valid elsewhere.

Examples: