2014-01-10

Using pre-formated text in a MediaWiki Template.

I needed to use <pre> tags in a MediaWiki template, which turned out to be non-trivial.  Using <code> and <poem> both fail to wrap single lines, as did the custom <div> styling.  It was easier to figure it out than add a bunch of <br>s to the source text.  For those looking for an ugly kludge, here you go. Enjoy.  (Non-salient bits removed: I do wrap the categories in <noinclude></noinclude>)

Template:P

pre style="margin-left:2em;font-weight: bold">

Template:PG

<{{p}}
{{{1|No Text Provided}}
</pre>

Usage:
{{PG|Some Text To Display Preformatted}}

Further Reading:

No comments: