ទំព័រគំរូ:Redirect4/doc
This is a documentation subpage for ទំព័រគំរូ:Redirect4. It may contain usage information, categories and other content that is not part of the original ទំព័រគំរូ page. |
Usage
[កែប្រែ]{{Str left|<string>|<count>}}
Gives the <count> substring of characters from the start of the trimmed string (the substring has length <count>).
If <count> is invalid, empty or zero, an empty string is returned. If undefined, it defaults to 1.
Limitations
[កែប្រែ]- Length to 500: The maximum substring stops at 500 long, yet gives no error message. Only 500 characters can be extracted even if the <string> is longer.
- Inexpensive (uses no other templates).
Examples
[កែប្រែ]- {{ Redirect4 | Lorem ipsum dolor sit amet | 10 }} → " Lorem ipsum dolor sit amet " និង " 10 " បានបញ្ជូនបន្តមកទីនេះ។ ចំពោះ other uses សូមមើល Lorem ipsum dolor sit amet (disambiguation) and 10 (disambiguation)។
- {{ Redirect4 | Lorem ipsum dolor sit amet | 1 }} → " Lorem ipsum dolor sit amet " និង " 1 " បានបញ្ជូនបន្តមកទីនេះ។ ចំពោះ other uses សូមមើល Lorem ipsum dolor sit amet (disambiguation) and 1 (disambiguation)។
- {{ Redirect4 | Lorem ipsum dolor sit amet | 0 }} → " Lorem ipsum dolor sit amet " និង " 0 " បានបញ្ជូនបន្តមកទីនេះ។ ចំពោះ other uses សូមមើល Lorem ipsum dolor sit amet (disambiguation) and 0 (disambiguation)។
- {{ Redirect4 | Lorem ipsum dolor sit amet | }} → " Lorem ipsum dolor sit amet " និង " " បានបញ្ជូនបន្តមកទីនេះ។ ចំពោះ other uses សូមមើល Lorem ipsum dolor sit amet (disambiguation) and (disambiguation)។
- {{ Redirect4 | Lorem ipsum dolor sit amet }} → " Lorem ipsum dolor sit amet " និង "{{{2}}}" បានបញ្ជូនបន្តមកទីនេះ។ ចំពោះ other uses សូមមើល Lorem ipsum dolor sit amet (disambiguation) and [[{{{2}}} (disambiguation)]]។
- {{ Redirect4 | Lorem ipsum dolor sit amet | 40 }} → " Lorem ipsum dolor sit amet " និង " 40 " បានបញ្ជូនបន្តមកទីនេះ។ ចំពោះ other uses សូមមើល Lorem ipsum dolor sit amet (disambiguation) and 40 (disambiguation)។
- {{ Redirect4 | àçé | 2 }} → " àçé " និង " 2 " បានបញ្ជូនបន្តមកទីនេះ។ ចំពោះ other uses សូមមើល àçé (disambiguation) and 2 (disambiguation)។
- This example is demonstrating the safety of this template with the UTF-8 encoding (this should work now) :
- {{ Redirect4 | Lorem ipsum dolor sit amet | 10 }} →
Examples of limitations
[កែប្រែ]All the limitations of use for this template and shown below are caused by the current implementation of the {{padleft:}} 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 is not safe with character entity references found in its string parameter :
- {{ Redirect4 | a c | 3 }} → " a c " និង " 3 " បានបញ្ជូនបន្តមកទីនេះ។ ចំពោះ other uses សូមមើល a c (disambiguation) and 3 (disambiguation)។
- This should display "a c", but the named character entity was partially truncated, leaving no length available for the final "c".
- {{ Redirect4 | aBc | 3 }} → " aBc " និង " 3 " បានបញ្ជូនបន្តមកទីនេះ។ ចំពោះ other uses សូមមើល aBc (disambiguation) and 3 (disambiguation)។
- This should display "abc", but the named character entity was partially truncated, leaving no length available for the final "c".
- {{ Redirect4 | a c | 3 }} → " a c " និង " 3 " បានបញ្ជូនបន្តមកទីនេះ។ ចំពោះ other uses សូមមើល a c (disambiguation) and 3 (disambiguation)។
- The result is correct, as expected.
- {{ Redirect4 | a c | 3 }} → " a c " និង " 3 " បានបញ្ជូនបន្តមកទីនេះ។ ចំពោះ other uses សូមមើល a c (disambiguation) and 3 (disambiguation)។
- This last example should be equivalent to the previous one, but it is not.
- {{ Redirect4 | a c | 3 }} →
The following example shows that the presence of some wiki markup that should be transparent and ignored, does not allow this template to work as expected (the nowiki section is replaced by a unique index string in the effective runtime value of the parameter ; this unique (43-bytes long) string starts by a control character (which will be finally filtered out from the generated HTML page if it remains in the result of this template), followed by "UNIQ" and some unique sequence and terminated by "QINU" and a final control character ; it is partially visible below, because the unique string is not complete after truncation, and then cannot be eliminated from the output in the first two lines):
- {{ Redirect4 | a<nowiki/>bc | 3 }} → " abc " និង " 3 " បានបញ្ជូនបន្តមកទីនេះ។ ចំពោះ other uses សូមមើល [[ abc (disambiguation)]] and 3 (disambiguation)។
- It effectively returns 3 bytes, but the \x07 (BELL) control in the second position is stripped out when generating the HTML displayed here.
- {{ Redirect4 | a<nowiki/>bc | 43 }} → " abc " និង " 43 " បានបញ្ជូនបន្តមកទីនេះ។ ចំពោះ other uses សូមមើល [[ abc (disambiguation)]] and 43 (disambiguation)។
- It effectively returns 43 bytes, but the \x07 (BELL) control in the second position is stripped out when generating the HTML displayed here, and the final \x07 was truncated
- {{ Redirect4 | a<nowiki/>bc | 44 }} → " abc " និង " 44 " បានបញ្ជូនបន្តមកទីនេះ។ ចំពោះ other uses សូមមើល [[ abc (disambiguation)]] and 44 (disambiguation)។
- It effectively returns 44 bytes, but the complete 43-bytes sequence is filtered out from the output wiki code when generating the final HTML, so there just remains the first leading "a" character .
- {{ Redirect4 | a<nowiki/>bc | 45 }} → " abc " និង " 45 " បានបញ្ជូនបន្តមកទីនេះ។ ចំពោះ other uses សូមមើល [[ abc (disambiguation)]] and 45 (disambiguation)។
- {{ Redirect4 | a<nowiki/>bc | 3 }} →
On the opposite, the HTML comments, and the "noinclude", "includeonly" and "onlyinclude" wiki markup tags are safe, because they are preprocessed in template parameters, before including it and substituing parameters:
- {{ Redirect4 | a<noinclude/>bc | 3 }} → " abc " និង " 3 " បានបញ្ជូនបន្តមកទីនេះ។ ចំពោះ other uses សូមមើល abc (disambiguation) and 3 (disambiguation)។
- {{ Redirect4 | a<!-- comment -->bc | 3 }} → " abc " និង " 3 " បានបញ្ជូនបន្តមកទីនេះ។ ចំពោះ other uses សូមមើល abc (disambiguation) and 3 (disambiguation)។
- {{ Redirect4 | a<noinclude/>bc | 3 }} →
Note also that the specified length will cause the input string to be padded by repeating it, it this length is larger than the input string length:
- {{ Redirect4 | Abc. | 10 }} → " Abc. " និង " 10 " បានបញ្ជូនបន្តមកទីនេះ។ ចំពោះ other uses សូមមើល Abc. (disambiguation) and 10 (disambiguation)។
- {{ Redirect4 | Abc. | 10 }} →
See also
[កែប្រែ]Description of all string templates
- Bugzilla:22555 - need for correcting padleft and padright functions, and to provide better string handling parser functions.