Template:Recipe: Difference between revisions
improved description; added examples of invalid calls |
Connecting to the new template modules that are easier to maintain |
||
| Line 1: | Line 1: | ||
<includeonly>{{#invoke: | <includeonly>{{#invoke: Recipe|render | ||
| product= {{{ 1|{{{product|}}} }}} | |||
| building={{{ 2|{{{building|}}} }}} | |||
| ingredient={{{ingredient|}}} | |||
}} | |||
</includeonly><noinclude> | </includeonly><noinclude> | ||
<code><nowiki>{{#invoke: | <code><nowiki>{{#invoke: Recipe|render | ||
| product= {{{ 1|{{{product|}}} }}} | |||
| building={{{ 2|{{{building|}}} }}} | |||
| ingredient={{{ingredient|}}} | |||
}}</nowiki></code> | |||
This template is used like this: | This template is used like this: | ||
<code><nowiki>{{Recipe|product|building}}</nowiki></code> | <code><nowiki>{{Recipe|product|building|ingredient}}</nowiki></code> | ||
Revision as of 21:44, 5 November 2023
{{#invoke: Recipe|render
| product= {{{ 1|{{{product|}}} }}}
| building={{{ 2|{{{building|}}} }}}
| ingredient={{{ingredient|}}}
}}
This template is used like this:
{{Recipe|product|building|ingredient}}
This template calls renderRecipe in Module:RenderRecipe to get recipes for a product and/or a building. This will generate a new wikitable full of content from the game: buildings, stars of efficiency, ingredients, and products.
This template standardizes the display of recipes throughout this wiki and greatly simplifies the amount of writing that is necessary when adding new content pages, especially for resources and buildings.
Usage
Giving the template both a product and a building will result in a table with exactly one recipe. Giving the template either a product or a building will result in a table with (usually) more than one row. If nothing is provided, an error will appear identifying the expectation.
Here are ways to call the template, as they would be written in the article calling the template:
| Argument | Examples | Expected outcome |
|---|---|---|
| None | {{Recipe}}
|
An error |
| Product and building | {{Recipe|Crystalized Dew|Brickyard}} {{Recipe|product=Crystalized Dew|building=Brickyard}}
|
A table with one row. |
| Product only | {{Recipe|Pie}} {{Recipe|product=Pie}}
|
A table with several rows, one for each building in which Pie can be produced. |
| Building only | {{Recipe||Scribe}} (note the double pipe) {{Recipe|building=Scribe}}
|
A table with several rows, one for each product that can be produced in the Scribe. |
Examples
The following are generated by calling the template, as shown in the examples in the table above.
1. {{Recipe|Crystalized Dew|Brickyard}} yields:
Script error: The function "render" does not exist.
2. {{Recipe|Pie}} yields:
Script error: The function "render" does not exist.
3. {{Recipe||Scribe}} yields:
Script error: The function "render" does not exist.
The following are error states generated by calling the template incorrectly.
4. With no arguments, {{Recipe}} yields:
Script error: The function "render" does not exist.
5. Skipping the double pipe AND not specifying that the provided name is the building in {{Recipe|Scribe}} yields:
Script error: The function "render" does not exist.
6. Mixing naming the arguments and not naming the arguments {{Recipe|product=Eggs|Ranch}} yields:
Script error: The function "render" does not exist.
7. Specifying products or buildings with no recipes {{Recipe|Market}} yields:
Script error: The function "render" does not exist.


