Jump to content
 







Main menu
   


Navigation  



Main page
Contents
Current events
Random article
About Wikipedia
Contact us
Donate
 




Contribute  



Help
Learn to edit
Community portal
Recent changes
Upload file
 








Search  

































Create account

Log in
 









Create account
 Log in
 




Pages for logged out editors learn more  



Contributions
Talk
 



















Contents

   



(Top)
 


1 Usage  



1.1  Anywhere you need a regular space  





1.2  Inserting a space inside a parser function  





1.3  Disabling default substitution  







2 TemplateData  





3 See also  














Template:Sp






Алтай тил
Аԥсшәа
العربية
Արեւմտահայերէն
Arpetan

Asturianu
Авар
Azərbaycanca
تۆرکجه
Basa Bali

 / Bân-lâm-gú
Башҡортса
Беларуская

Brezhoneg
Català
Чӑвашла
Čeština
Corsu
Dansk
Ελληνικά
Эрзянь
فارسی
Fiji Hindi
Føroyskt
Français
Galego
ГӀалгӀай
/Hak-kâ-ngî

Հայերեն
ि
Hrvatski
Ido
Ilokano
Ирон
Íslenska
Italiano
Jawa
Kabɩyɛ
Къарачай-малкъар

Қазақша
Kreyòl ayisyen
Kurdî
Кыргызча
Latina
Latviešu
Lëtzebuergesch
Ligure
Македонски

مصرى

 / Mìng-dĕ̤ng-nḡ
Мокшень
Монгол


Нохчийн
Occitan
ି
Oʻzbekcha / ўзбекча
ि

پښتو
Português
Română
Русский

Sardu
Scots
Shqip
Sicilianu

Simple English
سنڌي
Slovenščina
Soomaaliga
کوردی
Српски / srpski
Tagalog
Taqbaylit
Татарча / tatarça
 


Тоҷикӣ
Türkçe
Українська
اردو
Vèneto
Tiếng Vit

Zazaki

 
 

Edit links
 









Template
Talk
 

















Read
View source
View history
 








Tools
   


Actions  



Read
View source
View history
 




General  



What links here
Related changes
Upload file
Special pages
Permanent link
Page information
Get shortened URL
Download QR code
Wikidata item
 




Print/export  



Download as PDF
Printable version
 




In other projects  



Wikimedia Commons
Wikidata
 
















Appearance
   

 





Permanently protected template

From Wikipedia, the free encyclopedia
 


Usage

{{sp}} will insert a single, ordinary space character, using the numeric character reference  . It is a more readable alternative to using that code.

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

This is the TemplateData for this template used by TemplateWizard, VisualEditor and other tools. See a monthly parameter usage report for Template:Sp in articles based on its TemplateData.

TemplateData for Sp

Inserts a single space character; mainly used in parser functions

Template parameters[Edit template data]

This template prefers inline formatting of parameters.

ParameterDescriptionTypeStatus
No parameters specified

See also


Retrieved from "https://en.wikipedia.org/w/index.php?title=Template:Sp&oldid=750709055"

Categories: 
Inline spacing templates
Typing-aid templates
Hidden categories: 
Wikipedia template-protected templates
Templates using TemplateData
 



This page was last edited on 21 November 2016, at 11:11 (UTC).

Text is available under the Creative Commons Attribution-ShareAlike License 4.0; additional terms may apply. By using this site, you agree to the Terms of Use and Privacy Policy. Wikipedia® is a registered trademark of the Wikimedia Foundation, Inc., a non-profit organization.



Privacy policy

About Wikipedia

Disclaimers

Contact Wikipedia

Code of Conduct

Developers

Statistics

Cookie statement

Mobile view



Wikimedia Foundation
Powered by MediaWiki