Jump to content

Template talk:Str left

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia

Trimming

[edit]

I notice that this template trims the text before it gets the substring. I'm not sure how the string extensions do it, but I'd propose that we should try to keep the usages as similar as possible, in hopes that they might get installed at some point. --Amalthea 12:35, 31 March 2009 (UTC)[reply]

Huh, I forgot that I left that here, but let me second myself! In the same spirit, we might want to merge {{Trunc}} into this template, and decide how the handle the extreme cases (invalid length, no length, negative length, length greater than the string length). Again, it's probably advisable to have a look how the string extensions do it, and keep it in line with them, for an easier transition.
From what I can tell I'm responsible for most usages of this template, through the {{image}} template. As far as I can tell we can still merge the two without the differences having an effect. Amalthea 22:51, 13 May 2009 (UTC)[reply]
Str_left is not a built-in in the extension. Rather the equivalent would be {{#sub: text | 0 | length }} where #sub grabs arbitrary substrings and the zero tells it to start at the first character. Like all extension functions it will trim whitespace off text at both ends (this is actually parser behavior). If length is missing, not a number, or larger than the actual string length then it returns the whole string. If length is negative it returns abs(length) characters starting at the right end rather than the left. Dragons flight (talk) 23:47, 13 May 2009 (UTC)[reply]

Str right

[edit]

I guessing that the answer is no (because Template:Str right is currently red) but is there no possibly way to take characters from the end of a string? — Martin (MSGJ · talk) 22:58, 17 May 2009 (UTC)[reply]

You can build it using {{str sub}} and {{str len}}, but that has rather severe limitations, and performs rather badly. Amalthea 23:09, 17 May 2009 (UTC)[reply]
Oh nice. I just want to take off the first two characters. Template:Amg movie takes a parameter such as 1:356351 but the website has changed their links so now it just wants 356351. It would just be a temporary measure until we can get a bot to go round and change them all. — Martin (MSGJ · talk) 05:54, 18 May 2009 (UTC)[reply]

Update "Examples of limitations"

[edit]

MediaWiki's parser behavior has changed, and now some of the examples of limitations ouput does not match the description of that output. — SMcCandlish   Talk⇒ ɖ∘¿¤þ   Contrib. 22:59, 24 December 2012 (UTC)[reply]

In particular, the whole first section is wrong. Basically, it just needs to say that HTML character entities are seen literally, not as the character they are meant to represent. {{Str left|a c |3}} → a&n, literally the first three chars of the string. " " looks like just another 6-character string to the function, not a single non-breaking space. —[AlanM1(talk)]— 01:53, 27 February 2013 (UTC)[reply]