Difference between revisions of "Help:Template"
Views
Actions
Namespaces
Variants
Tools
(Add discussion link) |
m (emphasized link) |
||
Line 1: | Line 1: | ||
{{BoxDanger|Viewing the template inject syntax|You can examine how the templates are called by clicking the edit link. '''Never modify the templates''' as changes will reflect on all documents where the template is injected! Use this [[Help_talk:Template|discussion link]] before you make any changes.}} | {{BoxDanger|Viewing the template inject syntax|You can examine how the templates are called by clicking the edit link. '''Never modify the templates''' as changes will reflect on all documents where the template is injected! Use this '''[[Help_talk:Template|discussion link]]''' before you make any changes.}} | ||
==Using templates== | ==Using templates== |
Latest revision as of 10:59, 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 injecting a template looks like this
{{TemplateName|argument1|argument2}}
There are exceptions - when the argument contains the = operator - in which case the template is using named arguments and format for injecting a template with named arguments
{{File|file=filename|content=content}}
Template Collection
Command templates
To emphazise if an example command in a document is assuming root or user context
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.
# 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
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!}}