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 support for case with no separator (single item)
imported>MiamiVolts
close brackets
Line 1: Line 1:
<includeonly>{{#if:{{{text|}}}|{{#if:{{{sep|}}}|{{#ifeq:{{#rpos:{{{text}}}|{{{sep}}}}}||{{{text}}}|{{#sub:{{{text}}}|0|{{#expr:{{#rpos:{{{text}}}|{{{sep}}}}}+{{#len:{{{sep}}}}}}}}}{{#if:{{{andstr|}}}|{{{andstr}}}|&#x0020; and &#x0020;}}{{#sub:{{{text}}}|{{#expr:{{#rpos:{{{text}}}|{{{sep}}}}}+{{#len:{{{sep}}}}}}}}}}}|{{#ifeq:{{#rpos:{{{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>
<includeonly>{{#if:{{{text|}}}|{{#if:{{{sep|}}}|{{#ifeq:{{#rpos:{{{text}}}|{{{sep}}}}}||{{{text}}}|{{#sub:{{{text}}}|0|{{#expr:{{#rpos:{{{text}}}|{{{sep}}}}}+{{#len:{{{sep}}}}}}}}}{{#if:{{{andstr|}}}|{{{andstr}}}|&#x0020; and &#x0020;}}{{#sub:{{{text}}}|{{#expr:{{#rpos:{{{text}}}|{{{sep}}}}}+{{#len:{{{sep}}}}}}}}}}}|{{#ifeq:{{#rpos:{{{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>
== Usage ==
== Usage ==
This template acts as a function to convert a comma or other seperated 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 seperated 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.
Line 13: Line 13:
}}
}}
</pre>
</pre>
== Note ==
== Notes ==
* The input text is only altered if the specified separator, or the default "&amp;#44;", exists within it.
* The code
{{Nousercat|Templates}}
{{Nousercat|Templates}}
</noinclude>
</noinclude>

Revision as of 04:09, 22 December 2007

Usage

This template acts as a function to convert a comma or other seperated 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.