Template:Template style

From bg3.wiki
Jump to navigation Jump to search
Template documentation

Can be used to add CSS styles to templates. For example, a template page could contain code like this:

<includeonly>{{template style |
  CSS rules go here.
}}ACTUAL TEMPLATE CONTENT GOES HERE.</includeonly><noinclude>{{documentation | content =

Template documentation.

...

}}< / noinclude >

This basically just wraps a use of Extension:CSS (i.e. {{#css: ... }}) in some extra code that makes sure the style is only added once per page ("de-duplication") and not repeated for every use of the template.

The de-duplication is implemented by Module:Template style.

Note that this doesn't automatically wrap the style in {{hidden code}}, since that adds some overhead in case of templates that are called all over the place. So, be careful not to use this template on a line of its own, or it will turn into an empty paragraph.

Use {{page style}} if you want to add some CSS directly to a page, not tied to a template. That one skips the "de-duplication" code and uses {{hidden code}} implicitly, since you're unlikely to use it hundreds of times on a single page.

Example:

Markup
{{template style |
  .bg3wiki-foobar { color: red; }
}}<span class="bg3wiki-foobar">Example.</div>
Renders as
Example.