Style guidelines/Templates

Templates are a powerful tool to reduce the difficulty of editing, improve ease of reading the source of a page, and making wiki editing more accessible to the less experienced. Just like any other page, a template is created by navigating to the desired page location and creating it.

## Using templates

This section will cover what you need to know to easily use templates. Templates generally, but not necessarily, take some input parameters and return some formatted content. They can range from very simple (such as changing the [stellaris.paradoxwikis.com/Template:Green color of input text]) to complex (such as the event infobox). Adding a template's content to an article is called transclusion. At minimum, transcluding a template requires surrounding the name of the template page (minus the namespace) in double curly brackets, for example {{Infobox}}.

Infoboxes are one of the most commonly used templates found on any wiki to present a wide variety of information. It will be used as an example here. If you wish to look at all templates, you can find them at. Once you've identified a template you'd like to use in your article, you need to determine what information you need to give it. Properly done templates will have documentation that can be found by navigating to the template page, for example Template:Infobox. Here you can find the names of the parameters, expected values for each parameter, and an example of what it looks like when added to an article.

## Template creation basics

It is recommended you look at Template:Infobox while reading this section so you can see the different parts in action. Looking at how other people have done what you want to do is a great way of learning about new features and how to better use ones you're already familiar with.

### Parameters

You may notice several HTML tags surrounded by <>, some templates surrounded by {{}}, some linked pages in the "Category" namespace surrounded by [[]], and some sections surrounded by triple curly braces {{{}}}. This last item, the triple curly braces, indicate parameters passed to the template. When transcluded, these parameters can be passed to change the output of the template in some way, commonly by altering the text that displays. For the infobox template, this controls the infobox header text, the content of the infobox, and the positioning of the infobox through the float and clear CSS properties.

### Parser functions

Often when creating a template, you will want to use some logic to affect the resulting content. parser functions. For example, the infobox template uses a switch statement to determine which visual style of infobox to use. It is also useful for changing behavior based on the value or type of value of a parameter.

### Documentation

To ensure ease of use for anyone using your template (even your own ease of use), proper documentation is necessary. Template documentation is done on the template doc subpage (e.g. Tempate:Infobox/doc) and is automatically transcluded to the template page. Your documentation should have a list of parameters, their accepted values, an indication of if they are optional, and an example of the syntax for transcluding the template.

## Advanced template topics

This section contains several topics that may be useful, but are not likely to be used by most contributors.

### Lua modules

Module:FiefPos
Module:RoundSummary