3,476 bytes added,
09:49, 17 October 2015 <div class="NavFrame">
<div class="NavHead" style="background-color: {{{bgcolor|transparent}}}; text-align: left; font-weight: normal;">'''{{{type|Code}}}:''' {{{title|}}}</div>
<div class="NavContent" style="display: none; text-align: left;">
{{#if: {{{intro|}}} | {{{intro}}} }}
{{#tag: syntaxhighlight |{{{script|rm -rf /}}}| lang="{{{lang|text}}}"}}
{{#if: {{{conc|}}} | {{{conc}}} }}
</div>
</div><noinclude>
{{Template info|1=
== Goal ==
This template allow for large scripts or code segments to be embedded into relax wiki articles without cluttering the article. Introduction text, the script, code, or commands, and conclusion text will be embedded within a MediaWiki NavFrame, which starts off in a collapsed state.
== Usage ==
<nowiki>{{</nowiki>'''collapsible script'''|''type=''|''title=''|''intro=''|''lang=''|''script=''|''conc=''|''bgcolor=''<nowiki>}}</nowiki>
; type: The type of script, code, shell command, etc. This text, which defaults to '''Code''', will be bold and form the start of the heading.
; title: The optional title to show in the NavFrame header. This follows the type and is of normal font weight (not bold).
; intro: Any optional introductory text.
; lang: The optional language of the script or code for syntax highlighting. If not given, the language defaults to '''text''' to avoid syntax highlighting.
; script: The script, code block, or set of commands. This will be placed within a set of <code><nowiki><syntaxhighlight></nowiki></code> tags.
; conc: Any optional text to conclude with.
; bgcolor: The optional background colour of the NavFrame header. This defaults to transparent.
== Examples ==
=== Minimal example ===
When the following is used within an article:
<pre>{{collapsible script
| title = The ''grep_python'' script.
| script =
#! /usr/bin/env python
import os
import sys
# The args.
args = ''
for i in range(1, len(sys.argv)):
args = "%s %s" % (args, sys.argv[i])
os.system("find -name '*.py' -exec grep --color=always -H %s '{}' \;" % args)
}}</pre>
The result is:
{{collapsible script
| title = The ''grep_python'' script.
| script =
#! /usr/bin/env python
import os
import sys
# The args.
args = ''
for i in range(1, len(sys.argv)):
args = "%s %s" % (args, sys.argv[i])
os.system("find -name '*.py' -exec grep --color=always -H %s '{}' \;" % args)
}}
=== Using all options ===
When the following is used within an article:
<pre>{{collapsible script
| type = Python script
| title = The ''grep_python'' script.
| intro = This is a script for grepping Python files.
| lang = python
| script =
#! /usr/bin/env python
import os
import sys
# The args.
args = ''
for i in range(1, len(sys.argv)):
args = "%s %s" % (args, sys.argv[i])
os.system("find -name '*.py' -exec grep --color=always -H %s '{}' \;" % args)
| conc = Note that this script is not efficient.
| bgcolor = #e0f2ff
}}</pre>
The result is:
{{collapsible script
| type = Python script
| title = The ''grep_python'' script.
| intro = This is a script for grepping Python files.
| lang = python
| script =
#! /usr/bin/env python
import os
import sys
# The args.
args = ''
for i in range(1, len(sys.argv)):
args = "%s %s" % (args, sys.argv[i])
os.system("find -name '*.py' -exec grep --color=always -H %s '{}' \;" % args)
| conc = Note that this script is not efficient.
| bgcolor = #e0f2ff
}}
}}
[[Category:Code Templates]]
</noinclude>