Template:Specialization link: Difference between revisions

From Against the Storm Official Wiki
(created)
 
m (renaming first parameter to name for consistency with other link templates)
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
<includeonly>{{#invoke:SpecializationLink|renderLink|spec={{{1|{{{spec|}}} }}}|iconsize={{{2|{{{iconsize|}}} }}} }}</includeonly><noinclude>
<includeonly>{{#invoke:SpecializationLink|main
|name={{{name|{{{1|}}}}}}
|size={{{size|{{{2|}}}}}}
|display={{{display|}}}
}}</includeonly><noinclude>


<code><nowiki>{{#invoke:SpecializationLink|renderLink|spec={{{1|{{{spec|}}} }}}|iconsize={{{2|{{{iconsize|}}} }}} }}</nowiki></code>
{{Documentation}}


 
[[Category:Link templates]]
This template is used like this: <code><nowiki>{{Specialization link|spec|iconsize}}</nowiki></code>
[[Category:Lua-based modules]]</noinclude>
 
 
This template calls <code>renderLink</code> in '''Module:SpecializationLink''' to make icons and short wiki links to a specialization's page. The icon can be small, huge, or in between. The small icon is sized appropriately to fit well into in-line text.
 
This template standardizes the display of icons and specializations throughout the wiki and simplifies the amount of writing that is necessary when adding new content pages.
 
 
== Usage ==
 
Use the name of the specialization as it appears in the game.
 
Giving the template a specialization name will result in a text-sized icon and a link to the wiki page for that specialization . This is useful in-line with text in paragraphs, where specialization icons can still be recognized.
 
 
Telling the template what size to make the icon allows the icon to be larger and more distinguishable. This is useful when creating tables where a larger icon increases recognition. If you request a link to a specialization that doesn't exist, an error will appear.
 
The default is a small icon, for use in-line with text. You can also use <code>med</code>, <code>large</code>, <code>huge</code>, or write <code>small</code> explicitly, to describe the desired size of the icon, as you can see below.
 
 
Here are ways to call the template and the expected result:
 
{| class="wikitable"
! Argument !! Examples !! Expected outcome
|-
| None
|style="white-space: nowrap"| <code><nowiki>{{Specialization link}}</nowiki></code>
| An error.
|-
| Specialization name or <br /> Specialization name and a "small" icon size
|style="white-space: nowrap"| <code><nowiki>{{Specialization link|Farming}}</nowiki></code> <br /> <code><nowiki>{{Specialization link|Alchemy|small}}</nowiki></code>
| A small, text-sized icon and link to the wiki page for the specialization.
|-
| Specialization name and a "med" icon size
|style="white-space: nowrap"| <code><nowiki>{{Specialization link|Farming|med}}</nowiki></code> <br /> <code><nowiki>{{Specialization link|Meat production|med}}</nowiki></code>
| A fair-sized specialization icon and a link to its wiki page.
|-
| Specialization name and a "large" icon size
|style="white-space: nowrap"| <code><nowiki>{{Specialization link|Farming|large}}</nowiki></code> <br /> <code><nowiki>{{Specialization link|Wood|large}}</nowiki></code>
| A large specialization icon and a link to its wiki page.
|-
| Resource name and a "huge" icon size
|style="white-space: nowrap"| <code><nowiki>{{Specialization link|Farming|huge}}</nowiki></code> <br /> <code><nowiki>{{Specialization link|Engineering|huge}}</nowiki></code>
| A very large specialization icon and a link to its wiki page.
|}
 
 
== Examples ==
 
The following are generated by calling the template, as shown in the examples in the table above.
 
 
1. <code><nowiki>{{Specialization link|Farming}}</nowiki></code> yields:
 
{{Specialization link|Farming}}
 
 
2. <code><nowiki>{{Specialization link|Farming|med}}</nowiki></code> yields:
 
{{Specialization  link|Farming|med}}
 
 
3. <code><nowiki>{{Specialization link|Farming|large}}</nowiki></code> yields:
 
{{Specialization link|Farming|large}}
 
 
4. <code><nowiki>{{Specialization link|Farming|huge}}</nowiki></code> yields (currently the same as <code>large</code>, since the icons are not high enough resolution to render that big).
 
{{Specialization link|Farming|huge}}
 
 
The following are error messages generated by calling the template incorrectly.
 
 
5. With no arguments, <code><nowiki>{{Specialization link}}</nowiki></code> yields:
 
'''{{Specialization link}}'''
 
 
6. With the name of something that doesn't exist in the game, <code><nowiki>{{Specialization link|Meat}}</nowiki></code> yields:
 
'''{{Specialization link|Meat}}'''
 
 
7. With no specialization but an icon size, <code><nowiki>{{Specialization link||large}}</nowiki></code> yields:
 
'''{{Specialization link||large}}'''
 
 
Finally, providing an icon size that is not recognized does not break the template.
 
 
8. With a valid specialization but invalid icon size, <code><nowiki>{{Specialization link|Farming|gigantic}}</nowiki></code> yields:
 
{{Specialization link|Farming|gigantic}}</noinclude>

Latest revision as of 21:52, 8 November 2024


This is the Template Documentation from Template:Specialization link/doc.

Overview

Creates a link to a specialization's page.

The template validates that you have correctly spelled the specialization name, and it automatically looks up and includes the icon for you. Any links returned by this template should have articles and not be redlinks.

A shortcut exists for this template, Template:sl. You can use {{sl}} instead of {{Specialization link}} with the same parameters.

Parameters

Specialization

The name of the specialization is the only required parameter. Use it as it appears in-game; a missing or mispelled name will result in an error.

If you do not wish to write the code name=, you may skip that, but you must specify the specialization before any other parameters.

Parameter Type Description
name string Required. The name of the specialization, as it appears in the game.


Output overrides

All of these parameters are optional and change how the link is formatted.

Parameter Type Description
size string The size of the icon to display. Choose one of the following:
  • none
  • small
  • medium
  • large
  • huge (same as large for this template)

The default is small, suitable for paragraphs.

display string If you include display=notext only the icon will be rendered.

If you include display=show_type then Comfort or Proficiency will be added after the name, according to the specialization you specified.

Specialization links that are written into paragraphs should use the small icon, which is the default.

Examples

Basic usage

{{Specialization link|Masonry}}

Makes a simple link to the Masonry Masonry article with a small icon for use in-line in paragraphs like this. Please do not use larger icons than this in paragraphs or it will push the lines further apart, decreasing readability.


{{Specialization link|Masonry|size=medium}}

Yields a moderately sized icon, suitable for use in lists and tables.

Masonry Masonry


{{Specialization link|Masonry|large}}

Yields a large icon, suitable to headline tables focusing on specializations.

Masonry Masonry


Other examples

{{Specialization link|Meat production|none}}

Yields only the label Meat production, without an icon. As a great alternative to displaying the small icon after the first mention of the specialization in a paragraph, to avoid overwhelming the reader with icons.


{{Specialization link|Meat production|large|display=notext}}

Yields only the icon, and can be leverage the high recognizability of specialization graphics.

Meat production


{{Specialization link|Meat production|medium|display=show_type}}

Yields a longer label that includes the type of the specialization. Not as useful in most cases, but especially when comparing or grouping types of specializations.

Meat production Meat production (Proficiency)


{{Specialization link|Meat production|size=gigantic}}

Specifying an icon size that is not recognized does not return an error. Instead, it defaults to the small icon like this: Meat production Meat production.


Errors

The following are error messages generated by calling the template incorrectly.

{{Specialization link}}

With no arguments: Lua error in Module:SpecializationLink at line 39: The Specialization link template requires the name of a specialization.


{{Specialization link|name=Shipbuilding}}

Naming a specialization that doesn't exist in the game: Lua error in Module:SpecializationLink at line 56: No specialization found with that name: Shipbuilding.


{{Specialization link|large|Meat production}}

Swapping the order of the parameters so that the specialization is not first: Lua error in Module:SpecializationLink at line 56: No specialization found with that name: large.