Manjaro Difference between revisions of "Help:Template"

Difference between revisions of "Help:Template"

Help page
(Added information on the file content template)
(Rephrased the help page - added command templates)
Line 1: Line 1:
To use a template in any document reference the template and separate arguments with pipes '''|'''.
==Using templates==
Templates help to create a consistent look and feel to various elements.
A template is referenced using the '''TemplateName''' and one or more '''arguments'''.


As an example you can create a box to emphasize an important information
To use a template in any document reference the template and separate arguments with pipes '''|'''.
The general format for using a template is <code>{{TemplateName|argument1|argument2}}</code>.


<pre>{{Important|It is not possible to run `makepkg` as root!}}</pre>
There is an exception - when the argument contains the '''=''' operator - in which case the template is using a named argument like <code>{{File|file=filename|content=content}}</code>
 
==Command templates==
To emphazise a command in a document - to be run as either root or user
{{RootCmd|command=command}}
{{UserCmd|command=command}}
 
==File and content sample==
When you want to describe how to modify an given file's content. This is a little more work but produces a nice result. Because the content of configuration file often - if not always include '''=''' operator - it is necessary to use named variables when passing values to the template.
<pre>{{File|file=Filename|content=Content}}</pre>
The best result is achieved by using the '''pre''' tag inside the content.
{{File|file=~/.profile|
content=
<pre>
# set PATH so it includes user's private bin if it exists
export QT_QPA_PLATFORMTHEME="qt5ct"
export GTK2_RC_FILES="$HOME/.gtkrc-2.0"


Which will give this result in the final document
export EDITOR=/usr/bin/nano
export VISUAL=/usr/bin/nano
</pre>
}}


==Highlight boxes==
Boxes are helpers - they are not the document - so don't over-do it.
One way to draw attention to a point is the '''Important''' template which is a simplified verison of the '''BoxInfo template''' as you can see from below samples
<pre>{{Important|It is not possible to run `makepkg` as root!}}</pre>
{{Important|It is not possible to run `makepkg` as root!}}
{{Important|It is not possible to run `makepkg` as root!}}


Templates are helpers - they are not the document - so don't over do it.
You can utilize different boxtypes setting both the header and the content


{{BoxPrimary|Header|This is a BoxPrimary template}}
{{BoxPrimary|Header|This is a BoxPrimary template}}
Line 22: Line 45:
{{BoxDark|Header|This is a BoxDark template}}
{{BoxDark|Header|This is a BoxDark template}}


The same can be done when you need to describe how to modify an given file's content. This is a little more work but produces a nice result. Because the content of configuration file often if not always include '''=''' it is need to use named variables when passing values to the template.
You can examine how the templates are called by looking at the source of this document.
 
<pre>{{File|file=Filename|content=Content}}</pre>
 
The best result is achieved by using the '''pre''' inside the content.
 
{{File|file=~/.profile|
content=
<pre>
# set PATH so it includes user's private bin if it exists
export QT_QPA_PLATFORMTHEME="qt5ct"
export GTK2_RC_FILES="$HOME/.gtkrc-2.0"
 
export EDITOR=/usr/bin/nano
export VISUAL=/usr/bin/nano
</pre>
}}

Revision as of 08:09, 2 October 2020

Using templates

Templates help to create a consistent look and feel to various elements. A template is referenced using the TemplateName and one or more arguments.

To use a template in any document reference the template and separate arguments with pipes |. The general format for using a template is Template:TemplateName.

There is an exception - when the argument contains the = operator - in which case the template is using a named argument like

filename
content

Command templates

To emphazise a command in a document - to be run as either root or user

root # command COPY TO CLIPBOARD


user $ command COPY TO CLIPBOARD


File and content sample

When you want to describe how to modify an given file's content. This is a little more work but produces a nice result. Because the content of configuration file often - if not always include = operator - it is necessary to use named variables when passing values to the template.

{{File|file=Filename|content=Content}}

The best result is achieved by using the pre tag inside the content.

~/.profile
# set PATH so it includes user's private bin if it exists
export QT_QPA_PLATFORMTHEME="qt5ct"
export GTK2_RC_FILES="$HOME/.gtkrc-2.0"

export EDITOR=/usr/bin/nano
export VISUAL=/usr/bin/nano

Highlight boxes

Boxes are helpers - they are not the document - so don't over-do it. One way to draw attention to a point is the Important template which is a simplified verison of the BoxInfo template as you can see from below samples

{{Important|It is not possible to run `makepkg` as root!}}
Info
It is not possible to run `makepkg` as root!



Header
This is a BoxPrimary template
Header
This is a BoxSecondary template
Header
This is a BoxInfo template
Header
This is a BoxSuccess template
Header
This is a BoxWarning template
Header
This is a BoxDanger template
Header
This is a BoxLight template
Header
This is a BoxDark template

You can examine how the templates are called by looking at the source of this document.

Cookies help us deliver our services. By using our services, you agree to our use of cookies.