Wie Vorlagen verwendet werden

Versionsdaten
  • Versions-ID: 14076
  • Erstellt:
  • Autor: Thomas
  • Kommentar: 1. Übersetzung begonnen
  • Überprüft: Nein
  • Bereit zum Übersetzen: Nein
Quelltext der Version
Vorschau der Änderung

Vorlagen sind eine Möglichkeit, kleine Textbausteine wiederzuverwenden. Anstatt einen Text zwei Mal zu schreiben, kannst du ihn an einer Stelle erstellen und aktualisieren und in einer anderen Seite darauf verweisen. Die andere Seite wird immer aktuell bleiben, da sich die Änderungen der Vorlage automatisch übertragen!

Was sind Vorlagen

Eine Vorlage ist einfach eine besondere Wikiseite, deren Name mit „Template:“ beginnt. Es besitzt all die Eigenschaften einer normalen Wikiseite: Es kann übersetzt werden, hat eine Versionsgeschichte und versteht die Wiki-Syntax.

Wie erstelle ich ein Template

Eine Liste aller existierenden Vorlagen findest du unter hier (englisch).
  1. Erstelle einen neuen Wissensdatenbank-Artikel.
  2. Make sure the name begins with "Template:" - For example, Template:aboutconfig
  3. Set the Category to "Template"
  4. Continue writing the Template the same way you would any other Knowledge Base article.

How to include a Template in an Article

To use a template in a wiki page, all you have to do is "link" to the template. For example:

[[Template:Some Template]] or [[T:Some Template]]


Instead of creating a link, the content of Template:Some Template will be included into the current page. Any wiki markup in the template will be rendered.

Using arguments with a Template

Templates support passing in arguments, to let you reuse content that is almost the same.

Say, for example, you had a standard notice that told users that a document only applied to Firefox 4, and another version that said it only applied to Firefox 3.6. The text of those notices might be identical except for the Firefox version: a perfect time to use a template!

Template:OnlyVersionX:

{note}This document or section only applies to '''Firefox {{{1}}}'''!{/note}


Then, in one wiki page, you could do this:

[[Template:OnlyVersionX|4]]


And in another page, you could do:

[[Template:OnlyVersionX|3.6]]


You can use multiple arguments, or the same argument twice, too!

Template:XLikesY:

# {{{2}}} likes {{{1}}}.
# {{{3}}} likes {{{2}}}.
# Class! Nobody likes {{{2}}}!


Then to use it:

[[Template:XLikesY|Lisa|Milhouse|Janey]]


This would result in:

  1. Milhouse likes Lisa.
  2. Janey likes Milhouse.
  3. Class! Nobody likes Milhouse!


Keeping track of all those numbers can get confusing, so you can also name arguments to a template:

Template:XPrecededY:

First comes {{{first}}}, then comes {{{second}}}.


And using it:

[[Template:XPrecededY|first=love|second=marriage]]


With named arguments, you don't need to worry about the order when you use the template:

[[Template:XPrecededY|second=marriage|first=love]]


Both examples of using Template:XPrecededY will have the same result.