Template:Building link: Difference between revisions

From Against the Storm Official Wiki
(updated arg names)
(improved documentation, added examples)
Line 1: Line 1:
{{#invoke:BuildingLink|renderLink|building={{{1|}}}|iconsize={{{2|}}}}}<noinclude>
<includeonly>{{#invoke:BuildingLink|renderLink|building={{{1|{{{building|}}} }}}|iconsize={{{2|{{{iconsize|}}} }}} }}</includeonly><noinclude>


This template takes a building name and turns it into a link to the building. At larger sizes than standard text, an icon will also be included. Use the in-game name of the building (with or without spaces should work, as the background code contains some deconfliction). The default is no icon, for use in-line with text. You can also use <code>med</code>, <code>large</code>, or <code>huge</code>, as you can see below.
<code><nowiki>{{#invoke:BuildingLink|renderLink|building={{{1|{{{building|}}} }}}|iconsize={{{2|{{{iconsize|}}} }}} }}</nowiki></code>


For example:


<pre>{{Building_link|Cookhouse}}
This template is used like this: <code><nowiki>{{Building link|building|iconsize}}</nowiki></code>
{{Building_link|Cookhouse|med}}
 
{{Building_link|Cookhouse|large}}
 
{{Building_link|Cookhouse|huge}}</pre>
This template calls <code>renderLink</code> in '''Module:BuildingLink''' to make icons and short wiki links to a building's page. The icon can be missing, small, huge, or in between.
 
This template standardizes the display of icons and buildings throughout the wiki and simplifies the amount of writing that is necessary when adding new content pages.
 
 
A shortcut template also exists, <code><nowiki>{{bl}}</nowiki></code>, to make writing a page with many building links a little easier.
 
 
== Usage ==
 
Use the name of the building as it appears in the game. (The background code performs some normalization, but only to catch small mistakes in spacing or apostrophes.)
 
Giving the template a building name will result in a short link to the wiki page for that building. This is useful in-line with text in paragraphs, where an icon would be too small to recognize but anything large enough to recognize would disrupt the display of the lines of text when it tries to wrap around the icon.
 
 
Telling the template what size to make the icon will add an icon before the name of the building that also links to the wiki page. This is useful when creating tables where the building icon adds recognition. If the building is not known to the data modules behind the scenes, an error will appear.
 
The default is no icon, for use in-line with text. You can also use <code>med</code>, <code>large</code>, or <code>huge</code> 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>{{Building link}}</nowiki></code>
| An error.
|-
| Building name
|style="white-space: nowrap"| <code><nowiki>{{Building link|Cookhouse}}</code></nowiki> <br /> <code><nowiki>{{Building link|Carpenter}}</code></nowiki>
| A link to the wiki page for the building.
|-
| Building name and a "medium" icon size
|style="white-space: nowrap"| <code><nowiki>{{Building link|Cookhouse|med}}</code></nowiki> <br /> <code><nowiki>{{Building link|Kiln|med}}</code></nowiki>
| A small but recognizable building icon and a link to its wiki page.
|-
| Building name and a "large" icon size
|style="white-space: nowrap"| <code><nowiki>{{Building link|Cookhouse|large}}</code></nowiki>
| A large building icon and a link to its wiki page.
|-
| Building name and a "huge" icon size
|style="white-space: nowrap"| <code><nowiki>{{Building link|Cookhouse|huge}}</code></nowiki>
| A very large building 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>{{Building link|Cookhouse}}</nowiki></code> yields:


{{Building_link|Cookhouse}}
{{Building_link|Cookhouse}}
2. <code><nowiki>{{Building link|Cookhouse|med}}</nowiki></code> yields:


{{Building_link|Cookhouse|med}}
{{Building_link|Cookhouse|med}}
3. <code><nowiki>{{Building link|Cookhouse|large}}</nowiki></code> yields:


{{Building_link|Cookhouse|large}}
{{Building_link|Cookhouse|large}}


{{Building_link|Cookhouse|huge}}</noinclude>
 
4. <code><nowiki>{{Building link|Cookhouse|huge}}</nowiki></code> yields:
 
{{Building_link|Cookhouse|huge}}
 
 
The following are error messages generated by calling the template incorrectly.
 
 
5. With no arguments, <code><nowiki>{{Building_link}}</nowiki></code> yields:
 
'''{{Building_link}}'''
 
 
6. With the name of something that doesn't exist in the game, <code><nowiki>{{Building_link|Cookhuse}}</nowiki></code> yields:
 
'''{{Building_link|Cookhuse}}'''
 
 
7. With no building but an icon size, <code><nowiki>{{Building_link||large}}</nowiki></code> yields:
 
'''{{Building_link||large}}'''
 
 
Finally, providing an icon size that is not recognized does not break the template.
 
 
8. With a valid building but invalid icon size, <code><nowiki>{{Building link|Cookhouse|gigantic}}</nowiki></code> yields:
 
{{Building_link|Cookhouse|gigantic}}</noinclude>

Revision as of 17:33, 13 February 2023


{{#invoke:BuildingLink|renderLink|building={{{1|{{{building|}}} }}}|iconsize={{{2|{{{iconsize|}}} }}} }}


This template is used like this: {{Building link|building|iconsize}}


This template calls renderLink in Module:BuildingLink to make icons and short wiki links to a building's page. The icon can be missing, small, huge, or in between.

This template standardizes the display of icons and buildings throughout the wiki and simplifies the amount of writing that is necessary when adding new content pages.


A shortcut template also exists, {{bl}}, to make writing a page with many building links a little easier.


Usage

Use the name of the building as it appears in the game. (The background code performs some normalization, but only to catch small mistakes in spacing or apostrophes.)

Giving the template a building name will result in a short link to the wiki page for that building. This is useful in-line with text in paragraphs, where an icon would be too small to recognize but anything large enough to recognize would disrupt the display of the lines of text when it tries to wrap around the icon.


Telling the template what size to make the icon will add an icon before the name of the building that also links to the wiki page. This is useful when creating tables where the building icon adds recognition. If the building is not known to the data modules behind the scenes, an error will appear.

The default is no icon, for use in-line with text. You can also use med, large, or huge to describe the desired size of the icon, as you can see below.


Here are ways to call the template and the expected result:

Argument Examples Expected outcome
None {{Building link}} An error.
Building name {{Building link|Cookhouse}}</code>
{{Building link|Carpenter}}</code>
A link to the wiki page for the building.
Building name and a "medium" icon size {{Building link|Cookhouse|med}}</code>
{{Building link|Kiln|med}}</code>
A small but recognizable building icon and a link to its wiki page.
Building name and a "large" icon size {{Building link|Cookhouse|large}}</code> A large building icon and a link to its wiki page.
Building name and a "huge" icon size {{Building link|Cookhouse|huge}}</code> A very large building 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. {{Building link|Cookhouse}} yields:

Cookhouse


2. {{Building link|Cookhouse|med}} yields:

Cookhouse Cookhouse


3. {{Building link|Cookhouse|large}} yields:

Cookhouse Cookhouse


4. {{Building link|Cookhouse|huge}} yields:

Cookhouse Cookhouse


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


5. With no arguments, {{Building_link}} yields:

The Building Link template requires the a name of a building.


6. With the name of something that doesn't exist in the game, {{Building_link|Cookhuse}} yields:

No building found with provided name: Cookhuse.


7. With no building but an icon size, {{Building_link||large}} yields:

The Building Link template requires the a name of a building.


Finally, providing an icon size that is not recognized does not break the template.


8. With a valid building but invalid icon size, {{Building link|Cookhouse|gigantic}} yields:

Cookhouse