Template:FileBox/doc

From HPC Wiki
Revision as of 11:19, 15 December 2016 by Bgo (talk | contribs) (Created page with "{{Template}} <!-- Categories go at the bottom of this page. --> Displays a block element with a file contents, optionally providing syntax highlighting. A list of recognized...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to:navigation Jump to:search
Note
This page is a template. It contains some standardized, often used text, which can be transcluded inside other pages.

As this template is widely used in our wiki, it may be protected in which case only staff members can change it. Use the discussion page to propose enhancements or fixes, or to voice your opinion.

Displays a block element with a file contents, optionally providing syntax highlighting. A list of recognized languages for syntax highlighting can be found here.

Important
File contents may contain special characters (| or =) that break the MediaWiki templating system. You have these options to put the file contents (in order from preferred to rather-not-use) if you need to escape these characters:
  1. {{FileBox|1=contents}}
  2. {{FileBox|<nowiki>contents</nowiki>}}
  3. {{FileBox|<pre>contents</pre>}} (Syntax highlighting is broken using this invocation!)

Parameters

Parameter name Required? Default value Description
Anonymous parameter 1 Yes (n/a) File content
filename No (n/a) File name to display in the box header
title No (n/a) Additional title to display in the box header
lang No text Language of the contents, used for syntax highlighting

(here is a list of available languages)

Usage

See the template's testcases:

No parameter
Wiki code {{FileBox}}
Main version
FILE {{{filename}}}
{{{1}}}
Sandbox version
{{{title}}}
{{{1}}}
Parameters: filename=/tmp/file, 1=Some text/code.
Wiki code {{FileBox|filename=/tmp/file|1=Some text/code.}}
Main version
FILE File
Some text/code.
Sandbox version
{{{title}}}
Some text/code.
Parameters: title=FileBox example, 1=Some text/code.
Wiki code {{FileBox|title=FileBox example|1=Some text/code.}}
Main version
FILE {{{filename}}}FileBox example
Some text/code.
Sandbox version
FileBox example
Some text/code.
Parameters: title=FileBox example, filename=/tmp/file, 1=Some text/code.
Wiki code {{FileBox|title=FileBox example|filename=/tmp/file|1=Some text/code.}}
Main version
FILE /tmp/fileFileBox example
Some text/code.
Sandbox version
FileBox example
Some text/code.
Parameters: title=FileBox example, filename=/tmp/file, lang=bash, 1=#!/bin/bash echo "Hello, world!"
Wiki code {{FileBox|title=FileBox example|filename=/tmp/file|lang=bash|1=#!/bin/bash echo "Hello, world!" }}
Main version
FILE /tmp/fileFileBox example
#!/bin/bash
echo "Hello, world!"
Sandbox version
FileBox example
#!/bin/bash
echo "Hello, world!"

See also