User:Ian Spackman/NowrapList

From Wikipedia, the free encyclopedia

This template was designed to be used in creating well-formated lists of links in footer navagation boxes with adjacent items set apart by mid-dots (or other separators).

Its key feature is that individual items which contain spaces will not end up broken between two lines and hence be harder for the reader to recognize. Rather, line breaks will only occur immediately after the separator.

An example of such a box follows.

Contents

[edit] Usage

{{User:Ian Spackman/NowrapList |item1 | item2 | item3 | […] }}

[edit] Examples

[edit] Basic Example

The basic usage, and probably most useful, is simply a list of items, which will normally be links, marked off by the pipe symbol (|), with exactly one space, and no carriage returns, on each side of it.

{{Ian Spackman/NowrapList | [[Bardolino]] | [[Brenzone]] | [[Castelnuovo del Garda]] | [[Desenzano del Garda]] | [[Garda (VR)|Garda]] | [[Gardone Riviera]] | [[Gargnano]] | [[Lazise]] | [[Limone sul Garda]] | [[Lonato]] | [[Malcesine]] | [[Manerba del Garda]] | [[Moniga del Garda]] | [[Nago-Torbole]] | [[Padenghe sul Garda]] | [[Peschiera del Garda]] | [[Riva del Garda]] | [[Salò]] | [[San Felice del Benaco]] | [[Sirmione]] | [[Tignale]] | [[Torri del Benaco]] | [[Toscolano-Maderno]] | [[Tremosine]] }}

Bardolino · Brenzone · Castelnuovo del Garda · Desenzano del Garda · Garda · Gardone Riviera · Gargnano · Lazise · Limone sul Garda · Lonato · Malcesine · Manerba del Garda · Moniga del Garda · Nago-Torbole · Padenghe sul Garda · Peschiera del Garda · Riva del Garda · Salò · San Felice del Benaco · Sirmione · Tignale · Torri del Benaco · Toscolano-Maderno · Tremosine

[edit] Example with title and custom separator character

Using the same list as before, but adding title and separator parameters

| title = settlements
| separator = •
| [[Bardolino]] | [[Brenzone]] | […] | [[Tremosine]]

Settlements:   Bardolino Brenzone Castelnuovo del Garda Desenzano del Garda Garda Gardone Riviera Gargnano Lazise Limone sul Garda Lonato Malcesine Manerba del Garda Moniga del Garda Nago-Torbole Padenghe sul Garda Peschiera del Garda Riva del Garda Salò San Felice del Benaco Sirmione Tignale Torri del Benaco Toscolano-Maderno Tremosine

[edit] Example with ‘special’ characters

Certain characters need special handling:

  • = (the equals sign) cannot be used directly but needs to be replaced by {{Equals}} or (equivalently) the HTML entity =
  • | (the pipe symbol) works just fine within a piped link, but otherwise replace it with {{!}}

:| title = Equalities :| separator = {{!}} :| III {{equals}} 3 | XX {{equals}} 20 | MCMLIII {{equals}} 1953 | IV {{equals}} 4 | XX1 = 21 - 0 | IV = 2²}}

Equalities:   III = 3 | = 20 | MCMLIII = 1953 | IV = 4 | XX1 = 21 - 0 | IV = 2²

[edit] Example with an image used as separator

You probably shouldn’t, but you can use an image to separate the list items

| separator = [[Image:Dot10.png]]

Bardolino Image:Dot10.png Brenzone Image:Dot10.png Castelnuovo del Garda Image:Dot10.png Desenzano del Garda Image:Dot10.png Garda Image:Dot10.png Gardone Riviera Image:Dot10.png Gargnano Image:Dot10.png Lazise Image:Dot10.png Limone sul Garda Image:Dot10.png Lonato Image:Dot10.png Malcesine Image:Dot10.png Manerba del Garda Image:Dot10.png Moniga del Garda Image:Dot10.png Nago-Torbole Image:Dot10.png Padenghe sul Garda Image:Dot10.png Peschiera del Garda Image:Dot10.png Riva del Garda Image:Dot10.png Salò Image:Dot10.png San Felice del Benaco Image:Dot10.png Sirmione Image:Dot10.png Tignale Image:Dot10.png Torri del Benaco Image:Dot10.png Toscolano-Maderno Image:Dot10.png Tremosine

[edit] Applying styles to the separator

Here the separator is a the heart character (Unicode: 2665), with the colour set to red. Not a very good thing to do: but documented.

| separator = <span style=color:red;font-size:.8em;>♥</span>

Don’t do this:   Bardolino Brenzone Castelnuovo del Garda Desenzano del Garda Garda Gardone Riviera Gargnano Lazise Limone sul Garda Lonato Malcesine Manerba del Garda Moniga del Garda Nago-Torbole Padenghe sul Garda Peschiera del Garda Riva del Garda Salò San Felice del Benaco Sirmione Tignale Torri del Benaco Toscolano-Maderno Tremosine

Here the separator is a couple of shape characters in white with a drop-shadow. But don’t do it if you want to preservea modicum of inter-platform compatibility!

| separator = <span style="color:white; text-shadow:black 0px 0px 6px;">◢◣</span>

Don’t do this:   Bardolino ◢◣ Brenzone ◢◣ Castelnuovo del Garda ◢◣ Desenzano del Garda ◢◣ Garda ◢◣ Gardone Riviera ◢◣ Gargnano ◢◣ Lazise ◢◣ Limone sul Garda ◢◣ Lonato ◢◣ Malcesine ◢◣ Manerba del Garda ◢◣ Moniga del Garda ◢◣ Nago-Torbole ◢◣ Padenghe sul Garda ◢◣ Peschiera del Garda ◢◣ Riva del Garda ◢◣ Salò ◢◣ San Felice del Benaco ◢◣ Sirmione ◢◣ Tignale ◢◣ Torri del Benaco ◢◣ Toscolano-Maderno ◢◣ Tremosine

[edit] The ‘traditional approach’

Compare the above to the following. Resize your window and watch the word-wrapping behaviour. (Incidentally you may spot another difference: this template uses a plain mid-dot as a divider while {{·}} emboldens it.)

<b>Settlements:</b> [[Bardolino]]{{·}} [[Brenzone]]{{·}} [[Castelnuovo del Garda]]{{·}} [[Desenzano del Garda]]{{·}} [[Garda (VR)|Garda]]{{·}} [[Gardone Riviera]]{{·}} [[Gargnano]]{{·}} [[Lazise]]{{·}} [[Limone sul Garda]]{{·}} [[Lonato]]{{·}} [[Malcesine]]{{·}} [[Manerba del Garda]]{{·}} [[Moniga del Garda]]{{·}} [[Nago-Torbole]]{{·}} [[Padenghe sul Garda]]{{·}} [[Peschiera del Garda]]{{·}} [[Riva del Garda]]{{·}} [[Salò]]{{·}} [[San Felice del Benaco]]{{·}} [[Sirmione]]{{·}} [[Tignale]]{{·}} [[Torri del Benaco]]{{·}} [[Toscolano-Maderno]]{{·}} [[Tremosine]]

Settlements: Bardolino · Brenzone · Castelnuovo del Garda · Desenzano del Garda · Garda · Gardone Riviera · Gargnano · Lazise · Limone sul Garda · Lonato · Malcesine · Manerba del Garda · Moniga del Garda · Nago-Torbole · Padenghe sul Garda · Peschiera del Garda · Riva del Garda · Salò · San Felice del Benaco · Sirmione · Tignale · Torri del Benaco · Toscolano-Maderno · Tremosine

[edit] Known limitations and bugs

  • A better name for the template could be found
  • Parameters beyond the two-hundredth are silently ignored

[edit] C source

The template was generated using the following code:

#include <stdio.h>

int main (int argc, const char * argv[]) {
        int max = 200;
        int i;
        printf("{{ #if:{{{2|}}}\n");
        for (i=1; i<=max; i++) {
                printf("|{{Nowrap|{{{%d}}}·}}| {{{%d|}}}}}{{#if:{{{%d|}}}\n", i, i, i + 2);
        }
        printf("|{{Nowrap|{{{%d}}}·}}| {{{%d|}}}}}", i, i);
        printf("<noinclude>\n");
        printf("{{/doc}}\n");
        printf("</noinclude>");
        return 0;
}