Mall:Ns/dok

Från Wikipedia
Ej att förväxla med det magiska ordet {{ns:}}

Mallen {{ns}} infogar mellan 0 och 83 hårda mellanslag, i enlighet med det tal man anger som första (namnlösa) parameter. Om ingen parameter anges, eller om den är annat än siffror, infogas tre hårda mellanslag.

Användning och exempel[redigera wikitext]

Tre{{ns}}mellanslag{{ns}}mellan{{ns}}varje{{ns}}ord ger: Tre   mellanslag   mellan   varje   ord
Tio{{ns|10}}åtta{{ns|8}}sex{{ns|6}}fyra{{ns|4}}! ger: Tio          åtta        sex      fyra    !

Det synliga resultatet av {{ns|10}} är samma som att skriva in 10 stycken   i följd.

{{Ns}} fungerar även vid omformning av text till versaler. Jämför:

  • {{uc: Början{{ns|4}}slut }} → BÖRJAN    SLUT
  • {{uc: Början{{spaces|4}}slut }} → BÖRJAN    SLUT

Vid behov av mer än 83 mellanslag kan mallen upprepas, såsom "{{ns|80}}{{ns|10}}" för att infoga 90 hårda mellanslag.

Performance considerations[redigera wikitext]

{{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.

Se även[redigera wikitext]