Help:Templates

Help page
Revision as of 19:43, 16 October 2023 by Willowisp (talk | contribs) (Willowisp moved page Help:Template to Help:Templates)

A Template is a special type of page designed to be included within other pages. Templates are often used as 'shorthand' to automatically insert frequently-used images, code, and formatting on a page. We use templates extensively on bg3.wiki.

See the Template Quick Reference for an overview of the most commonly-used templates, or continue reading for examples of various templates.

Templates are powerful tools and can become very complex. For a much more in-depth look into templates, see MediaWiki Help:Templates.

Page creation templates

We use templates like WeaponPage to maintain a clean, consistent style across a large number of pages that share similar properties, such as Spells, Weapons, and other Equipment. These templates take your input in the form of standard parameters and use it to generate a pre-formatted page, optimise the page for search engines and embedded social media links, and add the page to the appropriate categories.

Examples:

Another great benefit of this approach is that it allows us to populate database tables with the provided information. For example, every time you add a new item to the wiki using the appropriate page template, it automatically adds the item to a database table which can be queried from elsewhere. This is, for example, how the lists on weapon type pages like Longswords are generated.

Data querying templates

When information is added to the wiki using an appropriate page creation template, the information is also made available in a database table. These tables can be queried from other pages, to display the data there as well, instead of having to link the user to the original page, or having to copy-paste the content.

For example, when you visit the page of a spell that inflicts Bleeding, you want to see the effects of the condition right then and there, instead of having to navigate to another page. If we copy-pasted the description of the condition into every page that mentions it, we would have a lot of work to do if a patch for the game changed how the condition works! For this reason, the condition is defined once, using the Condition Page template, and other pages query the data to display it.

Writing these queries can be quite complicated. So, the wiki offers templates that do the heavy lifting for you. A primary example is the Condition template, which you provide with the name of a condition, and it queries the data for you, displaying the effects of that condition in a nice format.

Other templates

Other templates can be used in a more focused fashion to insert frequently used, pre-formatted information or to add visual flair to a page, such as {{MediumArmour}} ( Medium armour) or {{action|bonus}} ( Bonus action). These types of templates are often embedded within other, larger templates like Page Creation Templates, but they can and should also be used on their own where appropriate.

Additional template examples:

Using templates

Add a template to a page

Inserting a template with the Visual Editor
  • When using the Visual Editor, select Insert > Template from the toolbar and start typing a template name. The visual editor may not always display documentation for the template or its parameters, so be sure to open the template's page for usage information.
  • When using the Source Editor, you can either copy and paste template code from an existing page, or newly invoke a template you're already familiar with by enclosing the template name in {{double curly braces}}. For example:
    • Code: This attack has {{Advantage}}
    • Result: This attack has Advantage Icon.png Advantage

Template parameters

Some templates have optional or required parameters that change the output of the template, giving it more versatility.

When invoking a template with parameters, separate each parameter with a pipe symbol |.

  • Template with one parameter:
    • Code: {{enchantment|+1}}
    • Result: Enchantment: + 1
  • Template with multiple parameters:
    • Code: {{AttributeBlock|8|15|7|6|10|8|hp=12|dex save = yes|race=Bird|hp=10}}
    • Result:

STR

8
(-1)

DEX

15
(+2)

CON

7
(-2)

INT

6
(-2)

WIS

10

CHA

8
(-1)

Creature Race Icon.png Race

Bird

HP Icon.png Hit Points

10

Template documentation

Template creators are encouraged to document (on the template's page itself as well as via the TemplateData button on the same page) how to use that template, including usage examples and accepted values for any template parameters. If you're unfamiliar with a particular template, navigate to its page to learn how it works. If a template page does not show any usage instructions, it could still be a work in progress, and you may want to check with its creator before using it.

See All Pages (Template namespace) for a full list of available templates on bg3.wiki.

More template examples

  • The {{DamageInfo}} and {{DamageText}} templates can insert pre-formatted damage information based on the parameters you provide, like so:
    • {{DamageInfo|2d6+1|Slashing|modifier=melee}} displays
      D6 Slashing.png 2d6 + 1 (3~13) + Strength modifier Damage TypesSlashing damage
    • {{DamageText|1d4|Fire}} displays 1d4Damage TypesFire, better for compact or inline usage
  • The {{Icon}} and {{SmallIcon}} templates help you add an icon to represent a spell or item, like so: