A Project of the Center for Advanced Study in the Visual Arts, National Gallery of Art
History of Early American Landscape Design

Template:Ns/doc

[http://www.nga.gov/content/ngaweb/research/casva/research-projects.html A Project of the National Gallery of Art, Center for Advanced Study in the Visual Arts ]

The Template:Ns inserts any count of non-breaking spaces (&#160;) as the number in parameter 1 (default: 3 spaces). The count is limited to 0-83 spaces, where 0 produces nothing. The intent is to provide a short markup template to insert extra spacing, rapidly, where text-wrapping is not wanted.

Usage:  3{{ns}}spaces{{ns}}here → 3   spaces   here

The effect of the count, such as in "{{ns|30}}" is identical to putting 30 copies of "&#160;" 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{{#INVOKE:STRING|REP|&NBSP;|4}}END

For gaps wider than 83 spaces, then multiple instances can be used, such as "{{ns|80}}{{ns|10}}" to insert 90 non-breaking spaces.

Performance considerations

The 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 wp:parser function {padleft:} to repeat "&#160;" 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 " &nbsp;" and hence, 3 spaces is the first gap needing longer markup. The short template name, "ns" avoids interleaving letters as "nsbp" for dyslexic users.

For gaps wider than 83 spaces, then multiple instances of {ns} can be used, such as "{{ns|80}}{{ns|10}}" to insert 90 non-breaking spaces.

TemplateData

This is the TemplateData documentation for the template used by the new VisualEditor.

Ns <templatedata>{

 "description": "Inserts a given number of non breaking spaces.",
 "params": {
   "1": {
     "label": "Number",
     "description": "The number of spaces to insert. Must be less than 83. The default is three spaces.",
     "type": "string",
     "required": false
   }
 }

}</templatedata>

See also

  • Template:In5 - to insert a mix of &nbsp and regular spaces which can wrap
  • Template:Gaps - to insert precisely-sized gaps between digits/words
  • Template:Spaces - to insert large, no-wrap span-tags to separate text 1-n spaces
  • Template:j - to join text or wikilinks as non-wrapped


Retrieved from "https://heald.nga.gov/mediawiki/index.php?title=Template:Ns/doc&oldid=2600"

History of Early American Landscape Design contributors, "Template:Ns/doc," History of Early American Landscape Design, , https://heald.nga.gov/mediawiki/index.php?title=Template:Ns/doc&oldid=2600 (accessed January 29, 2022).

A Project of the Center for Advanced Study in the Visual Arts

National Gallery of Art, Washington
https://heald.nga.gov/mediawiki/index.php/Template:Ns/doc
heald.nga.gov
crawl=CC-MAIN-2022-05
26247
application/http; msgtype=response
sha1:7DP7A4JTXRC5JZCIOAI3QBXRLMUAVI32
<urn:uuid:3611f717-d5ad-4ee2-a2e5-33264c479634>
2022-01-29T07:40:06Z
104.16.19.92
text/html
sha1:67PMDTR7GXHDVQWOFQ3E2GAINKZAVFQ2
<urn:uuid:0b2e23ec-d6f6-4b2f-8a8c-a5547fb3074e>
https://heald.nga.gov/mediawiki/index.php/Template:Ns/doc
response
<urn:uuid:23bae29a-6da8-47f7-a278-b016052d4f75>
isPartOf: CC-MAIN-2022-05
publisher: Common Crawl
description: Wide crawl of the web for January 2022
operator: Common Crawl Admin (info@commoncrawl.org)
hostname: ip-10-67-67-45
software: Apache Nutch 1.18 (modified, https://github.com/commoncrawl/nutch/)
robots: checked via crawler-commons 1.3-SNAPSHOT (https://github.com/crawler-commons/crawler-commons)
format: WARC File Format 1.1
conformsTo: https://iipc.github.io/warc-specifications/specifications/warc-format/warc-1.1/