Template:Sp/doc

Usage
will insert a single, ordinary space character.

Anywhere you need a regular space
You can use sp anywhere you need a regular, breaking space. If you need a non-breaking space or multiple spaces in a row, use space.

Inserting a space inside a parser function
Sometimes when using parser functions, you need to insert a space at the beginning or end of an optional message. sp can be used for that purpose. In the following examples, look closely at the spacing between words and punctuation to see the subtle differences.

I like green. The above example works fine if 'blue' does not have a value ('I like green.').
 * Example

However, if 'blue' is set to true, then the message is incorrectly run together ('I like greenand blue.').

I like green. Adding the space between 'green' and '&#123;&#123;#if' avoids running the 'green and' together, but now there will be an extra space if 'blue' is not set ('I like green .').

I like green. Adding the space between the pipe ('&#124;') and the word 'and' doesn't work. Any leading or trailing spaces from a parser function output are stripped, so this produces exactly the same output as the first example when 'blue' is true ('I like greenand blue.').

I like green. This one works! By inserting the sp in the parser function output, the space is not stripped, and the correct output is given whether blue is set to true ('I like green and blue.') or not set at all ('I like green.').

Disabling default substitution
Suppose you have a template, Example, that uses substitution, like this: When the template is transcluded and saved, the result would be interpreted as: message

You could override the substitution by setting the 'subst' attribute to sp: Now the result would be interpreted as: The extra blank space preceding the '#if' would not affect the template at all (except to suppress the default substitution).