Difference between revisions of "Template:Syntax"
From James Dooley's Wiki
(Created page with "{{#if: {{{2|}}}|'''Usage:'''|}}<div style="font-family: monospace,sans-serif; background-color:#F9F9F9; border: 1px solid #2F6FAB; overflow: auto; padding: 1em; word-wrap: bre...") |
|||
| Line 1: | Line 1: | ||
| − | {{#if: {{{2|}}}|'''Usage:'''|}}<div style="font-family: monospace,sans-serif; background-color:#F9F9F9; border: 1px solid #2F6FAB; overflow: auto; padding: 1em; word-wrap: break-word; {{{style|}}}">{{{1|}}}</div>{{#if: {{{2|}}}|<hr>'''Example:'''<div style="font-family: monospace,sans-serif; background-color:#F9F9F9; border: 1px solid #2F6FAB; overflow: auto; padding: 1em; word-wrap: break-word; {{{style|}}}">{{{2}}}</div>|}} | + | {{#if: {{{2|}}}|'''Usage:'''|}}<div style="font-family: monospace,sans-serif; background-color:#F9F9F9; border: 1px solid #2F6FAB; overflow: auto; padding: 1em; word-wrap: break-word; {{{style|}}}">{{{1|}}}</div>{{#if: {{{2|}}}|<hr>'''Example:'''<div style="font-family: monospace,sans-serif; background-color:#F9F9F9; border: 1px solid #2F6FAB; overflow: auto; padding: 1em; word-wrap: break-word; {{{style|}}}">{{{2}}}</div>|}}<noinclude> |
| + | ==Overview== | ||
| + | This is a simple wrapper template for use with <nowiki><source></source></nowiki> since it does not provide any styles. | ||
| + | The same styles that are used on the <nowiki><pre></pre></nowiki> will be applied to a <nowiki><div></div></nowiki> tag | ||
| + | |||
| + | ==Usage== | ||
| + | <pre> | ||
| + | {{syntax | ||
| + | |style= Allows for style overrides | ||
| + | |<Code to put inside the div tag>}} | ||
| + | </pre> | ||
| + | |||
| + | Please note that new lines will be processed as such, so you will want to put the template close at the very end of the code | ||
| + | |||
| + | |||
| + | {{mbox|type=info|size=small|msg=If the source has strange spacing it is likely due to the <nowiki><pre></nowiki> tags.|text= | ||
| + | You can fix this by including ''enclose='div''' in the <nowiki><source></nowiki> | ||
| + | |||
| + | Without enclose it may look like this: | ||
| + | {{syntax|<source lang='bash'> | ||
| + | pvcreate ${drbd_backing_device} | ||
| + | vgcreate drbd-${purpose} ${drbd_backing_device} | ||
| + | |||
| + | lvcreate -L 4G drbd-${purpose} -n metadata | ||
| + | lvcreate -L 4G drbd-${purpose} -n data | ||
| + | lvextend -l +95%FREE /dev/drbd-${purpose}/data | ||
| + | </source>|<source lang='bash'> | ||
| + | pvcreate /dev/sdb1 | ||
| + | vgcreate drbd-os /dev/sdb1 | ||
| + | |||
| + | lvcreate -L 4G drbd-os -n metadata | ||
| + | lvcreate -L 4G drbd-os -n data | ||
| + | lvextend -l +95%FREE /dev/drbd-os/data | ||
| + | </source>}} | ||
| + | |||
| + | With enclose it will look like this: | ||
| + | {{syntax|<source lang='bash' enclose='div'> | ||
| + | pvcreate ${drbd_backing_device} | ||
| + | vgcreate drbd-${purpose} ${drbd_backing_device} | ||
| + | |||
| + | lvcreate -L 4G drbd-${purpose} -n metadata | ||
| + | lvcreate -L 4G drbd-${purpose} -n data | ||
| + | lvextend -l +95%FREE /dev/drbd-${purpose}/data | ||
| + | </source>|<source lang='bash' enclose='div'> | ||
| + | pvcreate /dev/sdb1 | ||
| + | vgcreate drbd-os /dev/sdb1 | ||
| + | |||
| + | lvcreate -L 4G drbd-os -n metadata | ||
| + | lvcreate -L 4G drbd-os -n data | ||
| + | lvextend -l +95%FREE /dev/drbd-os/data | ||
| + | </source>}} | ||
| + | |||
| + | }} | ||
| + | |||
| + | ==Example== | ||
| + | |||
| + | <pre> | ||
| + | {{syntax | ||
| + | |style=border-width:3px; | ||
| + | |<syntaxhighlight lang=bash>echo "test" | less</syntaxhighlight>}} | ||
| + | </pre> | ||
| + | |||
| + | {{syntax | ||
| + | |style=border-width:3px; | ||
| + | |<syntaxhighlight lang=bash>echo "test" | less</syntaxhighlight>}} | ||
| + | |||
| + | ==Example with usage== | ||
| + | |||
| + | Providing a second line of code will put it inside the same block, this is useful if you are displaying the usage and then the example code | ||
| + | <pre> | ||
| + | |||
| + | {{syntax | ||
| + | |style=border-width:3px; | ||
| + | |<syntaxhighlight lang=bash>echo $message | less</syntaxhighlight> | ||
| + | |<syntaxhighlight lang=bash>echo "test" | less</syntaxhighlight>}} | ||
| + | </pre> | ||
| + | |||
| + | {{syntax | ||
| + | |style=border-width:3px; | ||
| + | |<syntaxhighlight lang=bash>echo $message |\ | ||
| + | less</syntaxhighlight>|<syntaxhighlight lang=bash>echo "test" |\ | ||
| + | less</syntaxhighlight>}} | ||
| + | </noinclude> | ||
Revision as of 11:11, 9 May 2013
Contents
Overview
This is a simple wrapper template for use with <source></source> since it does not provide any styles. The same styles that are used on the <pre></pre> will be applied to a <div></div> tag
Usage
{{syntax
|style= Allows for style overrides
|<Code to put inside the div tag>}}
Please note that new lines will be processed as such, so you will want to put the template close at the very end of the code
| If the source has strange spacing it is likely due to the <pre> tags. |
You can fix this by including enclose='div' in the <source>
Without enclose it may look like this:
Usage:pvcreate ${drbd_backing_device}
vgcreate drbd-${purpose} ${drbd_backing_device}
lvcreate -L 4G drbd-${purpose} -n metadata
lvcreate -L 4G drbd-${purpose} -n data
lvextend -l +95%FREE /dev/drbd-${purpose}/data
Example:
pvcreate /dev/sdb1
vgcreate drbd-os /dev/sdb1
lvcreate -L 4G drbd-os -n metadata
lvcreate -L 4G drbd-os -n data
lvextend -l +95%FREE /dev/drbd-os/data
With enclose it will look like this:
Usage:pvcreate ${drbd_backing_device}
vgcreate drbd-${purpose} ${drbd_backing_device}
lvcreate -L 4G drbd-${purpose} -n metadata
lvcreate -L 4G drbd-${purpose} -n data
lvextend -l +95%FREE /dev/drbd-${purpose}/data
Example:
pvcreate /dev/sdb1
vgcreate drbd-os /dev/sdb1
lvcreate -L 4G drbd-os -n metadata
lvcreate -L 4G drbd-os -n data
lvextend -l +95%FREE /dev/drbd-os/data
Example
{{syntax
|style=border-width:3px;
|<syntaxhighlight lang=bash>echo "test" | less</syntaxhighlight>}}
echo "test" | less
Example with usage
Providing a second line of code will put it inside the same block, this is useful if you are displaying the usage and then the example code
{{syntax
|style=border-width:3px;
|<syntaxhighlight lang=bash>echo $message | less</syntaxhighlight>
|<syntaxhighlight lang=bash>echo "test" | less</syntaxhighlight>}}
Usage:echo $message |\
less
Example:
echo "test" |\
less