Template:Pre

From Better Cities Wiki
Jump to: navigation, search


Summary

Displays a {{Tag|pre|open}} box but with wrapped or scrollable text. It also allows the box to contain formatting, to auto-size, or to be moved around the page (indentation, centering, etc.).

Adapted from Wikipedia template Pre2.

Parameters

1 required The text to be displayed.
scroll optional If a value is specified the box will be scrollable instead of wrapping.
width optional The width of the box. Note that unlike normal {{Tag|pre}} tags, width=auto will correctly auto-size the box.
nowiki optional If a value is specified, the text will be wrapped in {{Tag|nowiki|open}} tags. This will not work in all cases, see below.

Examples

Long Text

<pre style="width:auto; white-space:-moz-pre-wrap; white-space:-pre-wrap; white-space:-o-pre-wrap; white-space:pre-wrap; word-wrap:break-word;">{{Pre|Your really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really long text here.}} <pre style="width:auto; white-space:-moz-pre-wrap; white-space:-pre-wrap; white-space:-o-pre-wrap; white-space:pre-wrap; word-wrap:break-word;">Your really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really long text here.

Long Text with Scrolling

<pre style="width:auto; white-space:-moz-pre-wrap; white-space:-pre-wrap; white-space:-o-pre-wrap; white-space:pre-wrap; word-wrap:break-word;">{{Pre|Your really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really long text here.|scroll=yes}} <pre style="width:auto; overflow:auto;">Your really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really long text here.

Autosized to Short Text

{{Pre|Your<br>text here.|width=auto}}
<pre style="width:auto; white-space:-moz-pre-wrap; white-space:-pre-wrap; white-space:-o-pre-wrap; white-space:pre-wrap; word-wrap:break-word;">Your
text here.

Nowiki Variations

Parameter

{{Pre|Your wiki<br>text here.|nowiki=yes}}

<pre style="width:auto; white-space:-moz-pre-wrap; white-space:-pre-wrap; white-space:-o-pre-wrap; white-space:pre-wrap; word-wrap:break-word;">Your wiki<br>text here.

Parameter Fails

{{Pre|{{example}}|nowiki=yes}}

<pre style="width:auto; white-space:-moz-pre-wrap; white-space:-pre-wrap; white-space:-o-pre-wrap; white-space:pre-wrap; word-wrap:break-word;">[[:Template:Example]]

Nowiki Tags

{{Pre|<nowiki>{{example}}</nowiki>}}

<pre style="width:auto; white-space:-moz-pre-wrap; white-space:-pre-wrap; white-space:-o-pre-wrap; white-space:pre-wrap; word-wrap:break-word;">{{example}}