Template:Building link: Difference between revisions
(improved documentation, added examples) |
(Updated doc with examples other than production buildings.) |
||
Line 1: | Line 1: | ||
<includeonly>{{#invoke:BuildingLink|renderLink|building={{{1|{{{building|}}} }}}|iconsize={{{2|{{{iconsize|}}} }}} }}</includeonly><noinclude> | <includeonly>{{#invoke:BuildingLink|renderLink|building={{{1|{{{building|}}} }}}|iconsize={{{2|{{{iconsize|}}} }}} }}</includeonly><noinclude> | ||
== Overview == | |||
This template makes icons and short wiki links to a building's page. This template standardizes the display of icons and buildings throughout the wiki and simplifies the amount of writing needed. | |||
A shortcut template also exists, <code><nowiki>{{bl}}</nowiki></code>, and its use is encouraged to make writing links even easier. | |||
A shortcut template also exists, <code><nowiki>{{bl}}</nowiki></code>, to make writing | |||
== Usage == | == Usage == | ||
Use the name of the building as it appears in the game. | This template is used like this: <code><nowiki>{{Building link|building|iconsize}}</nowiki></code>. Use the name of the building as it appears in the game. | ||
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. | 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 aids recognition and where there is space to do so, for example in a table. If the building is not known to the data modules behind the scenes, an error will appear. | |||
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 | |||
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. | 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: | Here are ways to call the template and the expected result: | ||
{| class="wikitable" | {| class="wikitable" | ||
! | ! Parameter !! Examples !! Expected outcome | ||
|- | |- | ||
| None | | None | ||
Line 37: | Line 27: | ||
|- | |- | ||
| Building name | | Building name | ||
|style="white-space: nowrap"| <code><nowiki>{{Building link| | |style="white-space: nowrap"| <code><nowiki>{{Building link|Monastery}}</code></nowiki> | ||
| A link to the wiki page for the building. | | A link to the wiki page for the building. | ||
|- | |- | ||
| Building name and a "medium" icon size | | Building name and a "medium" icon size | ||
|style="white-space: nowrap"| <code><nowiki>{{ | |style="white-space: nowrap"| <code><nowiki>{{bl|Small Farm|med}}</code></nowiki> | ||
| A | | A moderately sized icon and a link to its wiki page. | ||
|- | |- | ||
| Building name and a "large" icon size | | Building name and a "large" icon size | ||
|style="white-space: nowrap"| <code><nowiki>{{ | |style="white-space: nowrap"| <code><nowiki>{{bl|Foragers' Camp|large}}</code></nowiki> | ||
| A large building icon and a link to its wiki page. | | A large building icon and a link to its wiki page. | ||
|- | |- | ||
| Building name and a "huge" icon size | | Building name and a "huge" icon size | ||
|style="white-space: nowrap"| <code><nowiki>{{ | |style="white-space: nowrap"| <code><nowiki>{{bl|Cookhouse|huge}}</code></nowiki> | ||
| A very large building icon and a link to its wiki page. | | A very large building icon and a link to its wiki page. | ||
|} | |} | ||
Line 58: | Line 48: | ||
The following are generated by calling the template, as shown in the examples in the table above. | The following are generated by calling the template, as shown in the examples in the table above. | ||
1. <code><nowiki>{{Building link|Monastery}}</nowiki></code> yields: | |||
{{Building_link|Monastery}} | |||
{{Building_link| | |||
2. <code><nowiki>{{ | 2. <code><nowiki>{{bl|Small Farm|med}}</nowiki></code> yields: | ||
{{ | {{bl|Small Farm|med}} | ||
3. <code><nowiki>{{bl|Foragers' Camp|large}}</nowiki></code> yields: | |||
{{bl|Foragers' Camp|large}} | |||
4. <code><nowiki>{{bl|Cookhouse|huge}}</nowiki></code> yields: | |||
4. <code><nowiki>{{ | |||
{{bl|Cookhouse|huge}} | |||
The following are error messages generated by calling the template incorrectly. | The following are error messages generated by calling the template incorrectly. | ||
5. With no arguments, <code><nowiki>{{Building_link}}</nowiki></code> yields: | 5. With no arguments, <code><nowiki>{{Building_link}}</nowiki></code> yields: | ||
'''{{Building_link}}''' | '''{{Building_link}}''' | ||
6. With the name of something that doesn't exist in the game, <code><nowiki>{{Building_link|Cookhuse}}</nowiki></code> yields: | 6. With the name of something that doesn't exist in the game, <code><nowiki>{{Building_link|Cookhuse}}</nowiki></code> yields: | ||
'''{{Building_link|Cookhuse}}''' | '''{{Building_link|Cookhuse}}''' | ||
7. With no building but an icon size, <code><nowiki>{{Building_link||large}}</nowiki></code> yields: | 7. With no building but an icon size, <code><nowiki>{{Building_link||large}}</nowiki></code> yields: | ||
'''{{Building_link||large}}''' | '''{{Building_link||large}}''' | ||
Finally, providing an icon size that is not recognized does not break the template. | 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: | 8. With a valid building but invalid icon size, <code><nowiki>{{Building link|Cookhouse|gigantic}}</nowiki></code> yields: | ||
{{Building_link|Cookhouse|gigantic}}</noinclude> | {{Building_link|Cookhouse|gigantic}}</noinclude> |
Revision as of 04:53, 27 November 2023
Overview
This template makes icons and short wiki links to a building's page. This template standardizes the display of icons and buildings throughout the wiki and simplifies the amount of writing needed.
A shortcut template also exists, {{bl}}
, and its use is encouraged to make writing links even easier.
Usage
This template is used like this: {{Building link|building|iconsize}}
. Use the name of the building as it appears in the game.
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 aids recognition and where there is space to do so, for example in a table. 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:
Parameter | Examples | Expected outcome |
---|---|---|
None | {{Building link}}
|
An error. |
Building name | {{Building link|Monastery}}</code>
|
A link to the wiki page for the building. |
Building name and a "medium" icon size | {{bl|Small Farm|med}}</code>
|
A moderately sized icon and a link to its wiki page. |
Building name and a "large" icon size | {{bl|Foragers' Camp|large}}</code>
|
A large building icon and a link to its wiki page. |
Building name and a "huge" icon size | {{bl|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|Monastery}}
yields:
Script error: The function "renderLink" does not exist.
2. {{bl|Small Farm|med}}
yields:
Script error: The function "renderLink" does not exist.
3. {{bl|Foragers' Camp|large}}
yields:
Script error: The function "renderLink" does not exist.
4. {{bl|Cookhouse|huge}}
yields:
Script error: The function "renderLink" does not exist.
The following are error messages generated by calling the template incorrectly.
5. With no arguments, {{Building_link}}
yields:
Script error: The function "renderLink" does not exist.
6. With the name of something that doesn't exist in the game, {{Building_link|Cookhuse}}
yields:
Script error: The function "renderLink" does not exist.
7. With no building but an icon size, {{Building_link||large}}
yields:
Script error: The function "renderLink" does not exist.
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:
Script error: The function "renderLink" does not exist.