Template:Sp/doc: Difference between revisions
already in navbox |
Caleb Cooper (talk | contribs) Created page with "{{Documentation subpage}} {{Commons Import}} <!-- PLEASE ADD CATEGORIES WHERE INDICATED AT THE BOTTOM OF THIS PAGE --> ==Usage== {{tlx|sp}} will insert a single, ordinary sp..." |
||
| Line 1: | Line 1: | ||
{{Documentation subpage}} |
{{Documentation subpage}} |
||
{{Commons Import}} |
|||
<!-- PLEASE ADD CATEGORIES WHERE INDICATED AT THE BOTTOM OF THIS PAGE --> |
<!-- PLEASE ADD CATEGORIES WHERE INDICATED AT THE BOTTOM OF THIS PAGE --> |
||
{{distinguish|template:sp?}} |
|||
==Usage== |
==Usage== |
||
{{tlx|sp}} will insert a single, ordinary space character. It can serve as a human-readable alternative to the <code>&#32;</code> [[numeric character reference]]. |
{{tlx|sp}} will insert a single, ordinary space character. It can serve as a human-readable alternative to the <code>&#32;</code> [[Wikipedia:numeric character reference|numeric character reference]]. |
||
===Anywhere you need a regular space=== |
===Anywhere you need a regular space=== |
||
| Line 10: | Line 11: | ||
===Inserting a space inside a parser function=== |
===Inserting a space inside a parser function=== |
||
Sometimes when using [[Help:parser functions|parser functions]], you need to insert a space at the beginning or end of an optional message. {{tl|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. |
Sometimes when using [[Wikipedia:Help:parser functions|parser functions]], you need to insert a space at the beginning or end of an optional message. {{tl|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. |
||
;Example |
;Example |
||
| Line 28: | Line 29: | ||
===Disabling default substitution=== |
===Disabling default substitution=== |
||
Suppose you have a template, {{tl|Example}}, that uses [[WP:substitution|substitution]], like this: |
Suppose you have a template, {{tl|Example}}, that uses [[Wikipedia:WP:substitution|substitution]], like this: |
||
<nowiki>{{{{{subst|subst:}}}#if{{{condition|}}}|message}}</nowiki> |
<nowiki>{{{{{subst|subst:}}}#if{{{condition|}}}|message}}</nowiki> |
||
When the template is [[WP:Transclusion|transcluded]] and saved, the result would be interpreted as: |
When the template is [[Wikipedia:WP:Transclusion|transcluded]] and saved, the result would be interpreted as: |
||
<nowiki>{{subst:#if{{{condition|}}}|message}}</nowiki> |
<nowiki>{{subst:#if{{{condition|}}}|message}}</nowiki> |
||
| Line 50: | Line 51: | ||
==See also== |
==See also== |
||
For documentation see wikipedia page [[wikipedia:Template:Sp]] |
|||
* {{tlx|fdw-iw}} – a template that uses {{tl|sp}} with parser functions |
|||
* {{tlx|verify spelling}} – for spelling issues |
|||
{{Inline spacing templates}} |
|||
<includeonly>{{Sandbox other|| |
<includeonly>{{Sandbox other|| |
||
Revision as of 18:14, 22 October 2020
| This page was automatically imported from Commons any changes will be overwritten, the source page is here () |
Usage
{{sp}} will insert a single, ordinary space character. It can serve as a human-readable alternative to the   numeric character reference.
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.
- Example
I like green{{#if:{{{blue|}}}|and blue}}.
The above example works fine if 'blue' does not have a value ('I like green.').
However, if 'blue' is set to true (|blue=true), then the message is incorrectly run together ('I like greenand blue.').
I like green {{#if:{{{blue|}}}|and blue}}.
Adding the space between 'green' and '{{#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{{#if:{{{blue|}}}| and blue}}.
Adding the space between the pipe ('|') 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{{#if:{{{blue|}}}|{{sp}}and blue}}.
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:
{{{{{subst|subst:}}}#if{{{condition|}}}|message}}
When the template is transcluded and saved, the result would be interpreted as:
{{subst:#if{{{condition|}}}|message}}
You could override the substitution by setting the 'subst' attribute to {{sp}}:
{{Example| subst={{sp}} }}
Now the result would be interpreted as:
{{ #if{{{condition|}}}|message}}
The extra blank space preceding the '#if' would not affect the template at all (except to suppress the default substitution).
TemplateData
TemplateData for Sp/doc
Inserts a single space character; mainly used in parser functions
| Parameter | Description | Type | Status | |||
|---|---|---|---|---|---|---|
| No parameters specified | ||||||
See also
For documentation see wikipedia page wikipedia:Template:Sp