Template:LastNameFirst: Difference between revisions
Jump to navigation
Jump to search
(slightly simpler logic) |
(adding exception for chants) |
||
Line 1: | Line 1: | ||
<includeonly>{{# | <includeonly>{{#switch: {{#explode:{{{1|{{PAGENAME}}}}}||-1}} |{{#explode:{{{1|{{PAGENAME}}}}}||0}} | ||
|{{ucfirst:{{{1|{{PAGENAME}}}}} }} | |chant = {{ucfirst:{{{1|{{PAGENAME}}}}} }} | ||
|{{ucfirst:{{#explode:{{{1|{{PAGENAME}}}}}||-1}}, {{#sub:{{{1|{{PAGENAME}}}}}||{{#expr:{{#len:{{{1|{{PAGENAME}}}}}}} - {{#len:{{#explode:{{{1|{{PAGENAME}}}}}||-1}}}} }} }} }} | |{{ucfirst:{{#explode:{{{1|{{PAGENAME}}}}}||-1}}, {{#sub:{{{1|{{PAGENAME}}}}}||{{#expr:{{#len:{{{1|{{PAGENAME}}}}}}} - {{#len:{{#explode:{{{1|{{PAGENAME}}}}}||-1}}}} }} }} }} | ||
}}</includeonly><noinclude><!-- | }}</includeonly><noinclude><!-- | ||
Line 13: | Line 13: | ||
: {{tl|LastNameFirst|Antonín Dvořák}} | : {{tl|LastNameFirst|Antonín Dvořák}} | ||
returns "{{LastNameFirst|Antonín Dvořák}}" (note that diacritics are not removed) | returns "{{LastNameFirst|Antonín Dvořák}}" (note that diacritics are not removed) | ||
: {{tl|LastNameFirst|Gregorian chant}} | |||
returns "{{LastNameFirst|Gregorian chant}}" (note that chant names are not inverted) | |||
}} | }} | ||
[[Category:Text formatting templates]] | [[Category:Text formatting templates]] | ||
</noinclude> | </noinclude> |
Revision as of 18:40, 23 April 2013
Converts a text in the form "Name(s) Surname" to the form "Surname, Name(s)".
Syntax:
- {{LastNameFirst}}
returns the contents of {{PAGENAME}} after processing it.
Syntax with an optional parameter:
- {{LastNameFirst|Antonín Dvořák}}
returns "Dvořák, Antonín" (note that diacritics are not removed)
- {{LastNameFirst|Gregorian chant}}
returns "Gregorian chant" (note that chant names are not inverted)