Difference between revisions of "Template:Short"

From FollowTheScore
Jump to: navigation, search
Line 2: Line 2:
 
This is not finished yet.
 
This is not finished yet.
 
==The template==
 
==The template==
<pre>{{#ifexpr:{{#len: {{{string|}}} }} > {{#expr:{{{count|25}}}+5}}|{{#sub:{{{string|}}}|0|{{{count|25}}}}}{{{suffix|}}}|{{{string|}}}}}</pre>
+
<pre>{{#ifexpr:{{#len: {{{string|}}} }} > {{#expr:{{{count|25}}}+5}}|{{#sub:{{{string|}}}|0|{{{count|25}}}}}{{{suffix|}}}|{{{string|}}}{{#if:{{{type|}}|url|]}}}}</pre>
  
 
==Usage==
 
==Usage==
This shortens strings. This can be used to shorten URLs or included text.
+
This shortens strings. This can be used to shorten URLs or included text.<br>Note: Requires [http://www.mediawiki.org/wiki/Extension:StringFunctions Extension:StringFunctions].
 +
 
 
===Usage===
 
===Usage===
 
<pre>{{Short
 
<pre>{{Short
Line 16: Line 17:
 
:It uses a tolerance of 5. So if you define count=10 the string will not be shortened if it is between 1 and 15 characters long.
 
:It uses a tolerance of 5. So if you define count=10 the string will not be shortened if it is between 1 and 15 characters long.
 
*'''suffix''': optional / default: " …" (not ...)
 
*'''suffix''': optional / default: " …" (not ...)
 +
  
 
===Examples===
 
===Examples===
<pre>{{Short|string=The number of displayed characters (white space / blanks are counted).|count=30|}}</pre>
+
<pre>{{Short|string=The number of displayed characters (white space / blanks are counted).|count=40}}</pre>
{{Short|string=The number of displayed characters (white space / blanks are counted).|count=30}}
+
'''Result:''' {{Short|string=The number of displayed characters (white space / blanks are counted).|count=40}}
 +
 
 +
<pre>{{Short|string=The number of displayed characters (white space / blanks are counted).|count=500}}</pre>
 +
The sring short than the count, nothing happens:<br>'''Result:''' {{Short|string=The number of displayed characters (white space / blanks are counted).|count=500}}
 
</noinclude>
 
</noinclude>

Revision as of 19:28, 23 July 2009

This is not finished yet.

The template

{{#ifexpr:{{#len: {{{string|}}} }} > {{#expr:{{{count|25}}}+5}}|{{#sub:{{{string|}}}|0|{{{count|25}}}}}{{{suffix|}}}|{{{string|}}}{{#if:{{{type|}}|url|]}}}}

Usage

This shortens strings. This can be used to shorten URLs or included text.
Note: Requires Extension:StringFunctions.

Usage

{{Short
|string =
|count  =
|suffix =
}}
  • count: optional / default: 25
The number of displayed characters (white space / blanks are counted).
It uses a tolerance of 5. So if you define count=10 the string will not be shortened if it is between 1 and 15 characters long.
  • suffix: optional / default: " …" (not ...)


Examples

{{Short|string=The number of displayed characters (white space / blanks are counted).|count=40}}

Result: Expression error: Unrecognized punctuation character "{".

{{Short|string=The number of displayed characters (white space / blanks are counted).|count=500}}

The sring short than the count, nothing happens:
Result: Expression error: Unrecognized punctuation character "{".