This wiki is a XML full dump clone of "Heroes Wiki", the main wiki about the Heroes saga that has been shut down permanently since June 1, 2020. The purpose of this wiki is to keep online an exhaustive and accurate database about the franchise.

Template:EnglishList: Difference between revisions

From Heroes Wiki
Jump to navigation Jump to search
Content deleted Content added
imported>MiamiVolts
add comments for readability
imported>MiamiVolts
try new version that gets rid of extra comma for 2 element lists
 
Line 1: Line 1:
<includeonly>{{#if:{{{text|}}}
<includeonly>{{#if:{{{text|}}}
|{{#if:{{{sep|}}}
|{{#if:{{{sep|}}}|<!--
|{{#ifeq:{{#pos:{{{text}}}|{{{sep}}}}}||<!-- if sep is not in specified text:
-->{{#ifeq:{{#pos:{{{text}}}|{{{sep}}}}}||<!-- if sep is not in specified text:
-->{{{text}}}|<!-- if sep is in specified text:
-->{{{text}}}|<!-- if sep is in specified text:
-->{{#sub:{{{text}}}|0|{{#expr:{{#rpos:{{{text}}}|{{{sep}}}}}+{{#len:{{{sep}}}<!--close len-->}}<!--close expr-->}}<!--close sub-->}}{{#if:{{{andstr|}}}|{{{andstr}}}|&#x0020; and &#x0020;}}{{#sub:{{{text}}}|{{#expr:{{#rpos:{{{text}}}|{{{sep}}}}}+{{#len:{{{sep}}}<!--close len-->}}<!--close expr-->}}<!--close sub-->}}<!--close ifeq-->}}|<!-- if sep is not specified, use &#44;
-->{{#sub:{{{text}}}|0|{{#expr:{{#rpos:{{{text}}}|{{{sep}}}}}+{{#if:{{EnglishList/ThreeOrMore|text={{{text}}}|sep={{{sep}}}}}|{{#len:{{{sep}}}<!--close len-->}}|0}}<!--close expr-->}}<!--close sub-->}}{{#if:{{{andstr|}}}|{{{andstr}}}|&#x0020; and &#x0020;}}{{#sub:{{{text}}}|{{#expr:{{#rpos:{{{text}}}|{{{sep}}}}}+{{#len:{{{sep}}}<!--close len-->}}<!--close expr-->}}<!--close sub-->}}<!--close ifeq-->}}|<!-- if sep is not specified, use &#44;
-->{{#ifeq:{{#pos:{{{text}}}|&#44;}}||{{{text}}}|{{#sub:{{{text}}}|0|{{#expr:{{#rpos:{{{text}}}|&#44;}}+5}}}}{{#if:{{{andstr|}}}|{{{andstr}}}|&#x0020; and &#x0020;}}{{#sub:{{{text}}}|{{#expr:{{#rpos:{{{text}}}|&#44;}}+5}}}}}}}}}}</includeonly><noinclude>
-->{{#ifeq:{{#pos:{{{text}}}|&#44;}}||<!-- if &#44; not in specified text:
-->{{{text}}}|<!-- if &#44; is in specified text:
-->{{#sub:{{{text}}}|0|{{#expr:{{#rpos:{{{text}}}|&#44;}}+{{#if:{{EnglishList/ThreeOrMore|text={{{text}}}|sep=&#44;}}|5|0}}}}}}{{#if:{{{andstr|}}}|{{{andstr}}}|&#x0020; and &#x0020;}}{{#sub:{{{text}}}|{{#expr:{{#rpos:{{{text}}}|&#44;}}+5}}}}}}}}}}</includeonly><noinclude>
== Usage ==
== Usage ==
This template acts as a function to convert a comma or other separated list string into an English list (a list with the word "and" or "or" before the last element). It is designed to be combined with inline DPL lists.
This template acts as a function to convert a comma or other separated list string into an English list (a list with the word "and" or "or" before the last element). It is designed to be combined with inline DPL lists.

Latest revision as of 00:28, 14 January 2009

Usage

This template acts as a function to convert a comma or other separated list string into an English list (a list with the word "and" or "or" before the last element). It is designed to be combined with inline DPL lists.

{{EnglishList
  |text=<List of items>
  |sep=<Optional separator string/character that exists between words;
         default is the ascii comma code (&#44;)>
  |andstr=<Optional string to use instead of " and ".
            A typical application may use " or " instead.
            Note: to get spacing correct, you need to use the ascii space code (&#x0020;)
             (i.e. "&#x0020; or &#x0020;")
}}

Notes

  • The input text is only altered if the specified separator, or the default "&#44;", exists within it.

Examples

{{EnglishList|text=1st item, 2nd item, 3rd item|sep=,}} 1st item, 2nd item, and 3rd item
{{EnglishList|text=1st item, 2nd item|sep=,}} 1st item and 2nd item
{{EnglishList|text=1st item|sep=,}} 1st item