Template:LastNameFirst: Difference between revisions

From ChoralWiki
Jump to navigation Jump to search
(Created page with "<includeonly>{{#ifexpr: {{#len:{{#explode:{{{1|{{PAGENAME}}}}}||-1}}}} = {{#len:{{{1|{{PAGENAME}}}}}}} |{{ucfirst:{{{1|{{PAGENAME}}}}} }} |{{ucfirst:{{#explode:{{{1|{{PAGENAME...")
 
(slightly simpler logic)
Line 1: Line 1:
<includeonly>{{#ifexpr: {{#len:{{#explode:{{{1|{{PAGENAME}}}}}||-1}}}} = {{#len:{{{1|{{PAGENAME}}}}}}}
<includeonly>{{#ifeq: {{#explode:{{{1|{{PAGENAME}}}}}||-1}} |{{#explode:{{{1|{{PAGENAME}}}}}||0}}
|{{ucfirst:{{{1|{{PAGENAME}}}}} }}
|{{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}}}} }} }} }}
Line 7: Line 7:


'''Syntax:'''
'''Syntax:'''
* <tt><nowiki>{{LastNameFirst}}</nowiki></tt> returns the contents of <tt><nowiki>{{PAGENAME}}</nowiki></tt> after processing it.
: {{tl|LastNameFirst}}
returns the contents of <tt><nowiki>{{PAGENAME}}</nowiki></tt> after processing it.


'''Syntax with an optional parameter:'''
'''Syntax with an optional parameter:'''
* <tt><nowiki>{{LastNameFirst|Antonín Dvořák}}</nowiki></tt> returns "{{LastNameFirst|Antonín Dvořák}}"
: {{tl|LastNameFirst|Antonín Dvořák}}
returns "{{LastNameFirst|Antonín Dvořák}}" (note that diacritics are not removed)
}}
}}
[[Category:Text formatting templates]]
[[Category:Text formatting templates]]
</noinclude>
</noinclude>

Revision as of 18:25, 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)