Template:Nb/doc: Difference between revisions
(Created page with "{{Documentation subpage}} __NOTOC__ ==Usage== {{tlf|'''nb'''}} inserts up to 10 consecutive non-breaking spaces at the position where the template is placed. The default, and...") |
(Corr. Added "Examples" section.) |
||
| Line 26: | Line 26: | ||
;<big>Usage</big> | ;<big>Usage</big> | ||
* {{tlc|nb|<big>'''1'''</big>}} | * {{tlc|nb|<big>'''1'''</big>}} | ||
==Examples== | |||
===Overriding wiki preformatting=== | |||
Any string or group of strings indented by a single space character will be pre-formatted and displayed in a box. | |||
;Example | |||
If you enter the code: | |||
<code><span style="color: #ffffff; background-color: #0095dd;"> </span>This text is pre-formatted.</code> | |||
the output will be: | |||
This text is pre-formatted. | |||
By using this template, you can override this function. | |||
;Example | |||
If you write: | |||
{{code|<nowiki>{{nb}}</nowiki>This text is pre-formatted.}} | |||
the output will be (notice the single space character indent): | |||
{{nb}}This text is pre-formatted. | |||
===Correct use=== | ===Correct use=== | ||
Latest revision as of 13:01, 10 January 2015
Usage
{{nb}} inserts up to 10 consecutive non-breaking spaces at the position where the template is placed.
The default, and intended action is to insert a single non-breaking space.
Parameters
There is only 1 parameter, which is unnamed and optional.
Syntax
The template's syntax is
{{nb|number value }}
To insert a single non-breaking space, you don't need to enter any parameter. Just type
{{nb}}
Optional parameter
1
- Number of inserted spaces
You can insert up to 10 characters by entering a number value (from 2 to 10) as the first parameter. This parameter is unnamed, so no parameter name has to be included.
- Note
- If the given value is invalid, the template will an error message.
- Usage
{{nb|1}}
Examples
Overriding wiki preformatting
Any string or group of strings indented by a single space character will be pre-formatted and displayed in a box.
- Example
If you enter the code:
This text is pre-formatted.
the output will be:
This text is pre-formatted.
By using this template, you can override this function.
- Example
If you write:
{{nb}}This text is pre-formatted.
the output will be (notice the single space character indent):
This text is pre-formatted.
Correct use
| Case | What you type | What you see | Comments |
|---|---|---|---|
| No parameter | Separate{{nb}}words |
Separate words | Inserts a non-breaking space |
Parameter |1 |
Even{{nb|2}}more{{nb|5}}separate{{nb|9}}words |
Even more separate words |
Incorrect use
| Case | What you type | What you see (error message) |
|---|---|---|
Value for |1 < 1 |
Separate{{nb|0}}words |
SeparateError in {{nbsp}}: number of spaces can't be 0 or negative, minimum is 1.words |
Value for |1 > 10 |
Separate{{nb|11}}words |
SeparateError in {{nbsp}}: too many spaces, maximum is 10.words |
See also
- {{sp}}: Inserts a single, regular space character. For use in templates, parser functions, and tables.
- {{space}}: Inserts any one of a number of different space characters.