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:
Building | Ingredient #1 options | Ingredient #2 options | Ingredient #3 options | Product | ||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
|
| 2 Crystalized Dew |
2. {{Recipe|Pie}}
yields:
Building | Ingredient #1 options | Ingredient #2 options | Ingredient #3 options | Product | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
| 10 Pie | |||||||||||||||||
|
|
| 10 Pie | |||||||||||||||||
|
|
| 10 Pie | |||||||||||||||||
|
|
| 10 Pie | |||||||||||||||||
|
|
| 10 Pie |
3. {{Recipe||Scribe}}
yields:
Building | Ingredient #1 options | Ingredient #2 options | Ingredient #3 options | Product | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
| 10 Ale | |||||||||||||||
|
|
| 8 Scrolls | |||||||||||||||
|
| 2 Pack of Trade Goods |
The following are error states generated by calling the template incorrectly.
4. With no arguments, {{Recipe}}
yields:
The Recipe template requires that you specify at least one of the following: product, building, or ingredient.
5. Skipping the double pipe AND not specifying that the provided name is the building in {{Recipe|Scribe}}
yields:
Lua error in Module:RecipeData at line 143: No product found. Please check spelling and any punctuation like an apostrophe: Scribe.
6. Mixing naming the arguments and not naming the arguments {{Recipe|product=Eggs|Ranch}}
yields:
Lua error in Module:RecipeData at line 143: No product found. Please check spelling and any punctuation like an apostrophe: Ranch.
7. Specifying products or buildings with no recipes {{Recipe|Market}}
yields:
Lua error in Module:RecipeData at line 274: No building found. Please check spelling and any punctuation like an apostrophe: Market.