• Home
  • Random
  • Log in
  • Settings
  • About Safer nicotine wiki
  • Disclaimers
Safer nicotine wiki

Template:Sp

  • Language
  • Watch
  • View source
Template documentation[view] [edit] [history] [purge]
Not to be confused with template:sp?.

Contents

  • 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

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

  • {{If}} - runs the laser function #if:, but retains whitespace
  • {{fdw-iw}} – a template that uses {{sp}} with parser functions
  • {{verify spelling}} – for spelling issues
  • v
  • t
  • e
Inline spacing templates
Non-breaking space characters
  • {{figure space}}
  • {{hair space}}
  • {{narrow no-break space}}
  • {{nb5}}
  • {{ns}}
  • {{quad}}
  • {{spaces}}
  • {{thin space}}
  • {{word joiner}}
  • {{zero width joiner}}
Breaking space characters
  • {{sp}}
  • {{zero width space}}
Non-character spaces
  • {{gaps}}
  • {{in5}}
  • {{indent}}
  • {{pad}}
  • {{px2}}
  • {{vpad}}
The above documentation is transcluded from Template:Sp/doc. (edit | history)
Editors can experiment in this template's sandbox (create | mirror) and testcases (create) pages.
Add categories to the /doc subpage. Subpages of this template.
Retrieved from "https://safernicotine.wiki/mediawiki/index.php?title=Template:Sp&oldid=20046"
Last edited on 5 December 2021, at 16:59
Cookies help us deliver our services. By using our services, you agree to our use of cookies.
More information

Languages

      This page is not available in other languages.

      Safer nicotine wiki
      • Creative Commons Attribution-ShareAlike
      • Powered by MediaWiki
      • Monitored by WikiApiary
      • ipv6 ready
      • Powered by Semantic MediaWiki
      • This page was last modified on 5 December 2021, at 16:59. Warning: Page may not contain recent updates.
      • Content is available under Creative Commons Attribution-ShareAlike unless otherwise noted.
      • Privacy policy
      • About Safer nicotine wiki
      • Disclaimers
      • Terms of Use
      • Desktop
      • Data access
      • Developers
      • Statistics
      • Cookie statement