Skabelon:Str rightc

Fra SpejderWiki
Spring til navigation Spring til søgning
[vis] [rediger]Template-info.svg Skabelon information

Skabelon:Documentation subpage

Usage

Skabelon:Tlx
Skabelon:Tlx

Gives a substring of length <count> characters from the right-side end of the string, or, if provided, returns <result if empty> when string is empty.

Examples

  • {{str rightc |Lorem ipsum dolor sit amet |10}} → {{safesubst:#invoke:String|sublength|s=Lorem ipsum dolor sit amet |i={{#invoke:Math|max}}|len=10}}
  • {{str rightc |Lorem ipsum dolor sit amet |1}} → {{safesubst:#invoke:String|sublength|s=Lorem ipsum dolor sit amet |i={{#invoke:Math|max}}|len=1}}
  • {{str rightc |Lorem ipsum dolor sit amet |0}} → {{safesubst:#invoke:String|sublength|s=Lorem ipsum dolor sit amet |i={{#invoke:Math|max}}|len=0}}
  • {{str rightc | |1 |string is empty}} → string is empty
  • {{str rightc |123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.1 |99}} → {{safesubst:#invoke:String|sublength|s=123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.1 |i={{#invoke:Math|max}}|len=99}}

TemplateData

Skabelon:TemplateDataHeader <templatedata> {

       "description": "Gives the right most <count> characters of a string.",
       "params": {
               "1": {
                       "label": "String",
                       "description": "The string to be trimmed",
                       "type": "string",
                       "required": true
               },
               "2": {
                       "label": "Count",
                       "description": "The number of characters from the right to return",
                       "type": "number",
                       "required": true
               },
               "3": {
                       "label": "result if empty",
                       "description": "The result if the string is empty",
                       "type": "string",
                       "required": false
               }
       }

} </templatedata>

See also