Anonymous user
Template:Str left/doc: Difference between revisions
m
move used in system template to top
(text editing) |
m (move used in system template to top) |
||
Line 1:
{{used in system}}
{{Documentation subpage}}
<!-- Categories go where indicated at the bottom of this page, please; interwikis go to Wikidata (see also: [[Wikipedia:Wikidata]]). -->
== Usage ==
: {{
Gives the resultant <count> of characters ''creating a substring of characters'' from the start of the [[w:Trim (programming)|trimmed]] string (i.e. the substring returned will have length <count>, exclusive of leading whitespace characters, which are trimmed first before <count> is invoked).
Line 24 ⟶ 28:
All the limitations of use for this template and shown below are caused by the current implementation of the <nowiki>{{padleft:}}</nowiki> parser function used in this template, which does not filter its third parameter containing the characters used for padding a string to the specified length (it currently counts incorrectly the characters to extract from the padding string, and incorrectly measures its effective length; in addition this parameter is limited to 500 bytes).
The following examples are demonstrating that this template
This template will erase nowiki tags without counting their length:
*: Returns three characters as expected
*: Returns three characters, but not aEb as might have been expected.
*: Returns 10 characters as expected.
:* <code><nowiki>{{</nowiki> {{BASEPAGENAME}} | a<noinclude/>bc | 3 <nowiki>}}</nowiki></code> → {{ {{BASEPAGENAME}} | a<noinclude/>bc | 3 }}
:* <code><nowiki>{{</nowiki> {{BASEPAGENAME}} | a<!-- comment -->bc | 3 <nowiki>}}</nowiki></code> → {{ {{BASEPAGENAME}} | a<!-- comment -->bc | 3 }}
Line 54 ⟶ 57:
<templatedata>
{
▲ "en": "A template to give the <count> substring of characters from the start of the trimmed string ",
"1": {
"label": "String",
▲ "params": {
},
"2": {
"label": "Count",
▲ "en": "The string to be trimmed and counted",
"required": true
}
}
▲ "type": "string",
▲ "en": "Gives the <count> substring of characters from the start of the trimmed string",
▲ "type": "number",
▲ "required": true
}
</templatedata>
== See also ==
* [[Bugzilla:22555]] (historical; need for correcting padleft/padright functions and to provide better string-handling parser functions)
{{String-handling templates |sub}}
<includeonly>{{Sandbox other||
|