Ad placeholder

Help:Templates: Difference between revisions

Jump to navigation Jump to search
491 bytes added ,  26 December 2023
no edit summary
No edit summary
No edit summary
Line 6: Line 6:
{{hatnote|This article is a technical guide to the creation of templates on BG3Wiki. For a guide on how to use templates, see [[Help:Using templates]]. See [[Help:List of templates]] for a list of templates.}}
{{hatnote|This article is a technical guide to the creation of templates on BG3Wiki. For a guide on how to use templates, see [[Help:Using templates]]. See [[Help:List of templates]] for a list of templates.}}
{{NavWiki|help}}
{{NavWiki|help}}
A template is a special type of page designed to be transcluded within other pages. Templates allow editors to automatically insert frequently-used images, code, and formatting on a page. We use templates extensively on BG3Wiki, as they allow the use of easily accessible and consistent design, layout and formatting.
A template is a special type of page designed to be transcluded within other pages. Templates allow editors to automatically insert frequently-used images, code, and formatting on a page.  


Templates allow for BG3Wiki to be partially automated. To ensure standardised practices across the wiki, this page provides guidelines for the process of '''template creation'''.
To ensure standardised practices across the wiki, this page provides guidelines for the process of '''template creation'''.


'''Template documentation''' is essential component of template creation, and ensures templates are well understood and used correctly across the wiki.
'''Template documentation''' is essential component of template creation, and ensures templates are well understood and used correctly across the wiki.
Line 18: Line 18:


=== Template page names ===
=== Template page names ===
Template page names should all be given in lower case letters with a single space between words.
Template page names should be given in lower case letters with a single space between words.


Note that the first letter of a template page name will always be considered capitalised, including when the template is linked to or transcluded.
Note that the first letter of a template page name will always be considered capitalised, including when the template is linked to or transcluded.


; Examples of template page names
; Examples of good template page names
* {{t link|}}
* {{t link|cite text}}
* {{t link|}}
* {{t link|relative location}}
* {{t link|}}
* {{t link|spell pags}}
 
==== Exceptions ====
Sometimes template names may consist of an abbreviation or a single word.
 
For example, {{t link|reflist}} is named as such because it adds a <nowiki><reference></nowiki> tag to list references. If it had been named <nowiki>{{reference list}}</nowiki> the name would have implies it's a list of or for {{em|reference}} tags instead.
 
Similarly, certain abbreviated names for templates such as {{t link|sai}}, {{t link|ref}} and {{t link|em}} are also considered acceptable, due to their simplicity.


=== Shortcuts ===
=== Shortcuts ===
To make templates easier to use, each template should have 1-5 ''shortcuts''. These are redirects which have shorter names for ease of access.
To make templates easier to use, each template should have 1-5 ''shortcuts''. These are redirects which have shorter names for ease of access. These do not need to follow the template page naming conventions.


As few shortcuts as possible should be created in order to prevent ambiguity. It a single shortcut is sufficient, then additional shortcuts {{em|should not}} be created.
As few shortcuts as possible should be created in order to prevent ambiguity. It a single shortcut is sufficient, then additional shortcuts {{em|should not}} be created.
Line 40: Line 47:


; Examples of shortcuts
; Examples of shortcuts
* {{t link|}}, redirects to {{t link|}}
* {{t link|"}}, redirects to {{t link|quote inline}}
* {{t link|}}, redirects to {{t link|}}
* {{t link|t link}}, redirects to {{t link|template link}}
* {{t link|}}, redirects to {{t link|}}
* {{t link|cw}}, redirects to {{t link|content warning}}


== Template creation guidelines ==
== Template creation guidelines ==
Line 81: Line 88:
* Links to similar or relevant templates.
* Links to similar or relevant templates.


 
=== How to include documentation ===
 
== How to include documentation ==
The template itself should be placed within the tag {{code|<nowiki><includeonly></includeonly></nowiki>}}. The template documentation should follow immediately after and should be placed within the tag {{code|<nowiki><noinclude></noinclude></nowiki>}} and use [[Template:Documentation]]. Be careful not to leave any unnecessary whitespace or line breaks! Example:
The template itself should be placed within the tag {{code|<nowiki><includeonly></includeonly></nowiki>}}. The template documentation should follow immediately after and should be placed within the tag {{code|<nowiki><noinclude></noinclude></nowiki>}} and use [[Template:Documentation]]. Be careful not to leave any unnecessary whitespace or line breaks! Example:
: {{code|<nowiki><includeonly>Template here.</includeonly><noinclude>{{documentation|content=Template documentation here.}}</noinclude></nowiki>}}
: {{code|<nowiki><includeonly>Template here.</includeonly><noinclude>{{documentation|content=Template documentation here.}}</noinclude></nowiki>}}
Line 96: Line 101:
Templates that have very long documentation can move the documentation (including template data) to the {{C|/doc}} subpage. The main page can simply contain {{c|<nowiki><noinclude>{{documentation}}</noinclude></nowiki>}}. The {{c|/doc}} subpage's contents will then automatically be transcluded on the template's page. Note that categories should remain on the main template page, still within the {{c|noinclude}} tags.
Templates that have very long documentation can move the documentation (including template data) to the {{C|/doc}} subpage. The main page can simply contain {{c|<nowiki><noinclude>{{documentation}}</noinclude></nowiki>}}. The {{c|/doc}} subpage's contents will then automatically be transcluded on the template's page. Note that categories should remain on the main template page, still within the {{c|noinclude}} tags.


== Writing template data ==
=== Writing template data ===
{{hatnote|For a thorough guide to TemplateData, see [https://m.mediawiki.org/wiki/Special:MyLanguage/Help:TemplateData Information about TemplateData]}}
{{hatnote|For a thorough guide to TemplateData, see [https://m.mediawiki.org/wiki/Special:MyLanguage/Help:TemplateData Information about TemplateData]}}
TemplateData can be managed by via the Template Documentation Menu, which can be opened via the "Manage TemplateData" button located above the Source Editor:
TemplateData can be managed by via the Template Documentation Menu, which can be opened via the "Manage TemplateData" button located above the Source Editor:
8,856
edits

Navigation menu