• Home
  • Random
  • Recent changes
  • Special pages
  • Settings
  • About MOASSpedia
  • Disclaimers
MOASSpedia
  • 216.73.216.154
  • Talk
  • Watchlist
  • Contributions
  • Log in

Template:Ns

Template Discussion
  • Language
  • Watch
  • History
  • Edit
    • Page information
    • Permanent link
    • What links here

   

Template documentation[view] [edit] [history] [purge]
This template inserts non-breaking (non-linewrapping) spaces. For the flag template "NS", see {{NS}}. For the magic word "{{ns:}}", see mw:Help:Magic words#Namespaces_2.
WarningThis template is used on approximately 2,300 pages and changes may be widely noticed. Test changes in the template's /sandbox or /testcases subpages, or in your own user subpage. Consider discussing changes on the talk page before implementing them.

Template:ns is designed to insert between 0 and 83 non-breaking (non-linewrapping) spaces rapidly according to the number assigned as its first (unnamed) parameter. If this parameter is not supplied or its value is not numeric, it inserts a default three non-breaking spaces.

Do not insert huge numbers of non-breaking spaces to achieve a particular article layout. The width of non-breaking spaces varies between platforms and fonts, and on mobile devices (over half of readers) they are likely to make content overflow the available width. Differences between fonts make them unsuitable for precisely matching the width of any other text; consider {{0}} to match the width of specific text.

Contents

  • 1 Usage and examples
  • 2 Performance considerations
  • 3 TemplateData
  • 4 See also

Usage and examples

Three{{ns}}spaces{{ns}}between{{ns}}each{{ns}}word produces: Three   spaces   between   each   word
Ten{{ns|10}}eight{{ns|8}}six{{ns|6}}four{{ns|4}}! produces: Ten          eight        six      four    !

The effect of the count, such as in "{{ns|30}}" is identical to putting 30 copies of " " into the text.

In translation of text to uppercase letters, the spacing is retained. Compare:

  • {{uc: Begin{{ns|4}}end }} → BEGIN    END
  • {{uc: Begin{{spaces|4}}end }} → BEGIN    END

Performance considerations

Template:ns has been designed to rapidly insert a few, or numerous, non-breaking spaces where wrapping is not wanted, such as to pad table headings or align some entries in columns. It has been clocked to run faster than 1,530x times per second (in December 2012). The number of spaces, from 0 to 83, does not affect the speed of formatting. It invokes the parser function "padleft:" to repeat " " several, or dozens, of times. Also, the expansion depth has been kept limited, as only 5 levels deep, to allow use anywhere, to generate spaces in any complex templates or tables.

Beyond the maximum count of 83 spaces, the template truncates at 500-characters long (limited by padleft), with "&#" at the end. The default count, as 3 spaces, was chosen because a 1-or-2-space gap is often coded as simply "  " and hence, 3 spaces is the first gap needing longer markup. The short template name, "ns" avoids transposing letters as "nsbp" for dyslexic users.

TemplateData

This is the TemplateData for this template used by TemplateWizard, VisualEditor and other tools. Click here to see a monthly parameter usage report for this template based on this TemplateData.

TemplateData for Ns

Inserts a given number of non breaking spaces.

Template parameters

ParameterDescriptionTypeStatus
Number1

The number of spaces to insert. Must be less than 83. The default is three spaces.

Stringoptional

See also

  • Template:nowrap, to join text or wikilinks as non-wrapped.
  • 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:Ns/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://moasspedia.org/w/index.php?title=Template:Ns&oldid=25526"
Categories:
  • Templates using TemplateData
  • Inline spacing templates
Last edited on 31 August 2015, at 09:29

MOASSpedia

Content is available under Creative Commons Attribution-ShareAlike unless otherwise noted.
  • This page was last edited on 31 August 2015, at 09:29.
  • Content is available under Creative Commons Attribution-ShareAlike unless otherwise noted.
  • Privacy policy
  • About MOASSpedia
  • Disclaimers
  • Desktop