Difference between revisions of "Template:Str len"

From Ava Zinn Wiki
Jump to: navigation, search
[unchecked revision][unchecked revision]
m (31 revisions from wikipedia:Template:Str len)
 
(21 intermediate revisions by 9 users not shown)
Line 1: Line 1:
{{#switch:*{{{1|}}}*
+
{{{{{|safesubst:}}}#ifeq: x{{{{{|safesubst:}}}#if:x|{{{1|}}}}} | x{{{{{|safesubst:}}}padleft:{{{1|}}}| 500 }}   <noinclude><!-- str >= 500 --></noinclude>
|**=0
+
| 500
|{{str_left|*{{{1}}}*|3}}=1
+
| {{{{{|safesubst:}}}str len/core  <noinclude><!-- xx0-xx9 --></noinclude>
|{{str_left|*{{{1}}}*|4}}=2
+
  |{{{{{|safesubst:}}}#if:x|{{{1|}}}}}
|{{str_left|*{{{1}}}*|5}}=3
+
  | {{{{{|safesubst:}}}str len/core  <noinclude><!-- x0x-x9x --></noinclude>
|{{str_left|*{{{1}}}*|6}}=4
+
    |{{{{{|safesubst:}}}#if:x|{{{1|}}}}}
|{{str_left|*{{{1}}}*|7}}=5
+
    | {{{{{|safesubst:}}}str len/core  <noinclude><!-- 0xx-4xx --></noinclude>
|{{str_left|*{{{1}}}*|8}}=6
+
      |{{{{{|safesubst:}}}#if:x|{{{1|}}}}}
|{{str_left|*{{{1}}}*|9}}=7
+
      | | hundreds
|{{str_left|*{{{1}}}*|10}}=8
+
      }}| tens
|{{str_left|*{{{1}}}*|11}}=9
+
    }}| ones
|{{str_left|*{{{1}}}*|12}}=10
+
  }}
|{{str_left|*{{{1}}}*|13}}=11
+
}}<noinclude>
|{{str_left|*{{{1}}}*|14}}=12
+
 
|{{str_left|*{{{1}}}*|15}}=13
+
{{documentation}}
|{{str_left|*{{{1}}}*|16}}=14
+
<!-- Add categories and interwikis to the /doc subpage, not here! -->
|{{str_left|*{{{1}}}*|17}}=15
+
</noinclude>
|{{str_left|*{{{1}}}*|18}}=16
 
|{{str_left|*{{{1}}}*|19}}=17
 
|{{str_left|*{{{1}}}*|20}}=18
 
|{{str_left|*{{{1}}}*|21}}=19
 
|{{str_left|*{{{1}}}*|22}}=20
 
|{{str_left|*{{{1}}}*|23}}=21
 
|{{str_left|*{{{1}}}*|24}}=22
 
|{{str_left|*{{{1}}}*|25}}=23
 
|{{str_left|*{{{1}}}*|26}}=24
 
|{{str_left|*{{{1}}}*|27}}=25
 
|{{str_left|*{{{1}}}*|28}}=26
 
|{{str_left|*{{{1}}}*|29}}=27
 
|{{str_left|*{{{1}}}*|30}}=28
 
|{{str_left|*{{{1}}}*|31}}=29
 
|{{str_left|*{{{1}}}*|32}}=30
 
|{{str_left|*{{{1}}}*|33}}=31
 
|{{str_left|*{{{1}}}*|34}}=32
 
|{{str_left|*{{{1}}}*|35}}=33
 
|{{str_left|*{{{1}}}*|36}}=34
 
|{{str_left|*{{{1}}}*|37}}=35
 
|{{str_left|*{{{1}}}*|38}}=36
 
|{{str_left|*{{{1}}}*|39}}=37
 
|{{str_left|*{{{1}}}*|40}}=38
 
|{{str_left|*{{{1}}}*|41}}=39
 
|{{str_left|*{{{1}}}*|42}}=40
 
|{{str_left|*{{{1}}}*|43}}=41
 
|{{str_left|*{{{1}}}*|44}}=42
 
|{{str_left|*{{{1}}}*|45}}=43
 
|{{str_left|*{{{1}}}*|46}}=44
 
|{{str_left|*{{{1}}}*|47}}=45
 
|{{str_left|*{{{1}}}*|48}}=46
 
|{{str_left|*{{{1}}}*|49}}=47
 
|{{str_left|*{{{1}}}*|50}}=48
 
|{{str_left|*{{{1}}}*|51}}=49
 
|{{str_left|*{{{1}}}*|52}}=50
 
|{{str_left|*{{{1}}}*|53}}=51
 
|{{str_left|*{{{1}}}*|54}}=52
 
|{{str_left|*{{{1}}}*|55}}=53
 
|{{str_left|*{{{1}}}*|56}}=54
 
|{{str_left|*{{{1}}}*|57}}=55
 
|{{str_left|*{{{1}}}*|58}}=56
 
|{{str_left|*{{{1}}}*|59}}=57
 
|{{str_left|*{{{1}}}*|60}}=58
 
|{{str_left|*{{{1}}}*|61}}=59
 
|{{str_left|*{{{1}}}*|62}}=60
 
|{{str_left|*{{{1}}}*|63}}=61
 
|{{str_left|*{{{1}}}*|64}}=62
 
|{{str_left|*{{{1}}}*|65}}=63
 
|{{str_left|*{{{1}}}*|66}}=64
 
|{{str_left|*{{{1}}}*|67}}=65
 
|{{str_left|*{{{1}}}*|68}}=66
 
|{{str_left|*{{{1}}}*|69}}=67
 
|{{str_left|*{{{1}}}*|70}}=68
 
|{{str_left|*{{{1}}}*|71}}=69
 
|{{str_left|*{{{1}}}*|72}}=70
 
|{{str_left|*{{{1}}}*|73}}=71
 
|{{str_left|*{{{1}}}*|74}}=72
 
|{{str_left|*{{{1}}}*|75}}=73
 
|{{str_left|*{{{1}}}*|76}}=74
 
|{{str_left|*{{{1}}}*|77}}=75
 
|{{str_left|*{{{1}}}*|78}}=76
 
|{{str_left|*{{{1}}}*|79}}=77
 
|{{str_left|*{{{1}}}*|80}}=78
 
|{{str_left|*{{{1}}}*|81}}=79
 
|{{str_left|*{{{1}}}*|82}}=80
 
|{{FormattingError|String longer than max string length of 80}}
 
}}
 

Latest revision as of 04:21, 7 March 2016

0

Documentation icon Template documentation[view] [edit] [history] [purge]

Template:Used in system

Gnome-utilities-terminal.svg This template uses (or will be using) Lua programming language.

Please see Wikipedia:Lua if you want to learn more about Lua or help convert other templates.

This is the {{str len}} meta-template.

It takes a string as parameter and returns its length (excluding spaces at the start and end). It can now count as high as necessary.

Examples[edit]

If the parameter is empty or undefined it is considered to be of zero length:

{{str len}} returns 0
{{str len|}} returns 0
{{str len| }} returns 0

It counts the length correctly, even if the string contains spaces, looks like a number, or contains special characters:

{{str len| ab cde }} returns 6
{{str len| 1234567 }} returns 7
{{str len| café åäö }} returns 8
{{str len| 499-characters... }} returns 499
{{str len| 1000-characters... }} returns 500

Template data[edit]

This is the TemplateData documentation for this template used by VisualEditor and other tools.

Str len

The template takes a string as parameter and returns its length, excluding spaces at the start and end of the string

Template parameters

ParameterDescriptionTypeStatus
Alpha-numeric text1

The string to be counted

Default
empty
Example
empty
Auto value
empty
Stringrequired

Technical details[edit]

This is the first general-purpose template to be implemented using mw:Extension:Scribunto. The Lua code is located in Module:String.

See also[edit]