Template:Str left/doc

Usage


Gives the resultant of characters creating a substring of characters from the start of the trimmed string (i.e. the substring returned will have length, exclusive of leading whitespace characters, which are trimmed first before is invoked).

If 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 is longer.
 * Inexpensive (uses no other templates).

Examples

 * &rarr;
 * &rarr; Lore, (note leading spaces trimmed!)
 * &rarr;
 * &rarr;
 * &rarr;
 * &rarr;
 * &rarr;
 * &rarr;
 * This example is demonstrating the safety of this template with the UTF-8 encoding (this should work now) :

Examples of limitations
All the limitations of use for this template and shown below are caused by the current implementation of the 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 does not interpret character entity references as the character they represent. It treats them as multiple characters and can leave them truncated.
 * &rarr;
 * The output "a c" may have been intended, but the named character entity was truncated, leaving no length available for the final "c".
 * &rarr;
 * This should display "abc", but the named character entity was truncated, leaving no length available for the final "c".
 * &rarr;
 * The result is correct, as expected.
 * &rarr;
 * This last example should be equivalent to the previous one, but it is not.

This template will erase nowiki tags without counting their length:
 * &rarr;
 * Returns three characters as expected
 * &rarr;
 * Returns three characters, but not aEb as might have been expected.
 * &rarr;
 * Returns 10 characters as expected.

HTML comments, and the "noinclude", "includeonly" and "onlyinclude" wiki markup tags are also ignored, because they are preprocessed in template parameters, before including it and substituting parameters:
 * &rarr;
 * &rarr;

Note also that the specified length will cause the input string to be padded by repeating it, if this length is larger than the input string length:
 * &rarr;

Template data
{       "description": "A template to give the substring of characters from the start of the trimmed string ", "params": { "1": {                       "label": "String", "description": "The string to be trimmed and counted", "type": "string", "required": true },               "2": {                        "label": "Count", "description": "Gives the substring of characters from the start of the trimmed string", "type": "number", "required": true }       } }