Template:Recipe/doc: Difference between revisions
(no longer needed) Tag: Blanking |
(Created to move documentation to a subpage) |
||
Line 1: | Line 1: | ||
== Overview == | |||
Creates a detailed table showing one or more recipes. | |||
Use whenever you need to show a wiki-linked, user-friendly, sortable, and always-up-to-date version of the in-game recipe book instead of a screenshot. You can get very specific and narrow down the table to only one recipe with the parameters. | |||
The table mimics the in-game recipe book with the building, efficiency grade and production time, ingredients, and product or service. | |||
The table is completely data-driven, based on the parameters. It validates input, retrieves all necessary data, and handles all formatting. | |||
The normal usage for this template produces a large table that typically fills the width of the article. (In rare cases, the table ''can'' overrun into the margin. This is a known issue and steps have already been taken to reduce the width of the table.) | |||
== Parameters == | |||
=== Product, Building, or Ingredient === | |||
'''At least one of these is required,''' and combinations are allowed. All names provided must be spelled (and, for buildings, punctuated) correctly to match the in-game name. These names will be the same as the articles for those goods and buildings. | |||
If you do not wish to write the code <code>product=</code> and <code>building=</code>, you may skip that. If you skip naming them, they must appear in that order, and you cannot skip the product name. The ingredient must always be named. In the future, because building names and resource names are mutually exclusive, this template may be made more flexible with the product and building parameter. | |||
{| class="wikitable" | |||
! Parameter !! Type !!colspan=2| Description | |||
|- | |||
| product || string || The name of the product or service associated with the recipe. (If you specify a service, '''do not''' change the parameter name from <code>product</code>.) | |||
|rowspan=3| '''At least<br />one of these<br /> is required.''' | |||
|- | |||
| building || string || The name of the building where the recipe is produced. | |||
|- | |||
| ingredient || string || The name of any ingredient in a recipe. | |||
|- | |||
| display || "list" ||colspan=2| If you include <code>display=list</code> it overrides the table display into a bulleted list of products or buildings (depending on which you specified). Useful for populating larger tables or between paragraphs where displaying the entire recipe is excessive or irrelevant. | |||
|} | |||
== Errors == | |||
When a product, service, building, or ingredient is not spelled correctly or is not a valid name, the template returns an error message to help you locate the spelling or name mistake. | |||
'''Example:''' | |||
Broken: <code><nowiki>{{Recipe|building=Alchemists' Hut}}</nowiki></code> | |||
{{Recipe|building=Alchemists' Hut}} | |||
Fixed: <code><nowiki>{{Recipe|building=Alchemist's Hut}}</nowiki></code> | |||
{{Recipe|building=Alchemist's Hut}} | |||
There may be cases where the name you should use to look up a good or building is not the right name. Please post these to this template's discussion page. | |||
== Examples == | |||
=== Basic Usage for Products and Buildings === | |||
A standard use of the template to show exactly one recipe for a product or service, in one building: | |||
<pre>{{Recipe|Crystalized Dew|Brickyard}}</pre> | |||
Yields: | |||
{{Recipe|Crystalized Dew|Brickyard}} | |||
Alternatively, for a service building: | |||
<pre>{{Recipe|Leisure|Tavern}}</pre> | |||
Yields: | |||
{{Recipe|Leisure|Tavern}} | |||
Here are several ways to call the template for products and buildings. | |||
{| class="wikitable mw-collapsible" | |||
! Parameter(s) !! Example(s) !! Expected outcome | |||
|- | |||
| no parameters || <code><nowiki>{{Recipe}}</nowiki></code> || an error | |||
|- | |||
| product (or service) and building | |||
|style="white-space: nowrap"| <code><nowiki>{{Recipe|Crystalized Dew|Brickyard}}</nowiki></code> <br> <code><nowiki>{{Recipe|product=Crystalized Dew|building=Brickyard}}</nowiki></code> | |||
| A table with exactly one row. | |||
|- | |||
| product (or service) only | |||
|style="white-space: nowrap"| <code><nowiki>{{Recipe|Pie}}</nowiki></code> <br> <code><nowiki>{{Recipe|product=Pie}}</nowiki></code> | |||
| A table with several rows, one for each building in which '''Pie''' can be produced. | |||
|- | |||
| building only | |||
|style="white-space: nowrap"| <code><nowiki>{{Recipe||Market}}</nowiki></code> ''(note the double pipe)'' <br> <code><nowiki>{{Recipe|building=Market}}</nowiki></code> | |||
| A table with several rows, one for each service provided by the '''Market.''' | |||
|- | |||
| product (or service), but with output override | |||
|style="white-space: nowrap| <code><nowiki>{{Recipe|Crystalized Dew|display=list}}</nowiki></code> | |||
| A short list of buildings and their efficiency stars that easily fit within another table:<br /> | |||
{{Recipe|Crystalized Dew|display=list}} | |||
|} | |||
=== Ingredients === | |||
Unlike when specifying the product (or service) and/or building, when you specify the ingredient, you explicitly must name the parameter with <code>ingredient=</code> in the template. Currently, you cannot select both a product and an ingredient (for example, all recipes where Berries are the ingredient and Pie is the product), because this is redundant with the product parameter by itself (since there is currently only one arrangement of ingredients and options that will make a product). | |||
The results of specifying the ingredient without also filtering on a building can display a long table. But on a resource's page, this information is expected to be valuable. | |||
<pre>{{Recipe|ingredient=Wine}}</pre> | |||
Yields: | |||
{{Recipe|ingredient=Wine}} | |||
<pre>{{Recipe|building=Lumber Mill|ingredient=Wine}}</pre> | |||
Yields: | |||
{{Recipe|building=Lumber Mill|ingredient=Wine}} | |||
=== Further Examples and Errors === | |||
The following are generated by calling the template as shown in the parameter examples table above. | |||
1. product and building: | |||
<pre>{{Recipe|Crystalized Dew|Brickyard}}</pre> | |||
Yields: | |||
{{Recipe|Crystalized Dew|Brickyard}} | |||
2. product only | |||
<pre>{{Recipe|Pie}}</pre> | |||
Yields: | |||
{{Recipe|Pie}} | |||
3. building only | |||
<pre>{{Recipe|building=Market}}</pre> | |||
Yields: | |||
{{Recipe|building=Market}} | |||
4. with the output override | |||
<pre>{{Recipe|Crystalized Dew|display=list}}</pre> | |||
Yields: | |||
{{Recipe|Crystalized Dew|display=list}} | |||
5 with the output override but specifying a building | |||
<pre>{{Recipe|building=Beanery|display=list}}</pre> | |||
Yields: | |||
{{Recipe|building=Beanery|display=list}} | |||
The following are error states generated by calling the template incorrectly. | |||
6. with no parameters | |||
<pre>{{Recipe}}</pre> | |||
Yields: | |||
{{Recipe}} | |||
7. using only one pipe and not specifying that the provided name is the building | |||
<pre>{{Recipe|Scribe}}</pre> | |||
Yields: | |||
{{Recipe|Scribe}} | |||
8. asking for products or buildings with no recipes | |||
<pre>{{Recipe|building=Small Warehouse}}</pre> | |||
Yields: | |||
{{Recipe|building=Small Warehouse}} |
Revision as of 03:24, 31 October 2024
Overview
Creates a detailed table showing one or more recipes.
Use whenever you need to show a wiki-linked, user-friendly, sortable, and always-up-to-date version of the in-game recipe book instead of a screenshot. You can get very specific and narrow down the table to only one recipe with the parameters.
The table mimics the in-game recipe book with the building, efficiency grade and production time, ingredients, and product or service.
The table is completely data-driven, based on the parameters. It validates input, retrieves all necessary data, and handles all formatting.
The normal usage for this template produces a large table that typically fills the width of the article. (In rare cases, the table can overrun into the margin. This is a known issue and steps have already been taken to reduce the width of the table.)
Parameters
Product, Building, or Ingredient
At least one of these is required, and combinations are allowed. All names provided must be spelled (and, for buildings, punctuated) correctly to match the in-game name. These names will be the same as the articles for those goods and buildings.
If you do not wish to write the code product=
and building=
, you may skip that. If you skip naming them, they must appear in that order, and you cannot skip the product name. The ingredient must always be named. In the future, because building names and resource names are mutually exclusive, this template may be made more flexible with the product and building parameter.
Parameter | Type | Description | |
---|---|---|---|
product | string | The name of the product or service associated with the recipe. (If you specify a service, do not change the parameter name from product .)
|
At least one of these is required. |
building | string | The name of the building where the recipe is produced. | |
ingredient | string | The name of any ingredient in a recipe. | |
display | "list" | If you include display=list it overrides the table display into a bulleted list of products or buildings (depending on which you specified). Useful for populating larger tables or between paragraphs where displaying the entire recipe is excessive or irrelevant.
|
Errors
When a product, service, building, or ingredient is not spelled correctly or is not a valid name, the template returns an error message to help you locate the spelling or name mistake.
Example:
Broken: {{Recipe|building=Alchemists' Hut}}
Lua error in Module:RecipeController at line 160: You must specify a product, building, or ingredient. Please see the template documentation for how to use the parameters.
Fixed: {{Recipe|building=Alchemist's Hut}}
Building | Grade | Ingredient #1 | Ingredient #2 | Ingredient #3 | Product | |||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
★★ 1:24 |
— |
|
|
10 Wine | |||||||||||||||||||||||
|
★★ 2:06 |
|
|
|
10 Tea | |||||||||||||||||||||||
|
★★ 0:42 |
|
|
|
2 Crystalized Dew |
There may be cases where the name you should use to look up a good or building is not the right name. Please post these to this template's discussion page.
Examples
Basic Usage for Products and Buildings
A standard use of the template to show exactly one recipe for a product or service, in one building:
{{Recipe|Crystalized Dew|Brickyard}}
Yields:
Building | Grade | Ingredient #1 | Ingredient #2 | Ingredient #3 | Product | |||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
★ 0:42 |
|
|
|
2 |
Alternatively, for a service building:
{{Recipe|Leisure|Tavern}}
Yields:
Building | Grade | Ingredient | Product | |||
---|---|---|---|---|---|---|
|
★ 0:00 |
|
1 |
Here are several ways to call the template for products and buildings.
Parameter(s) | Example(s) | Expected outcome |
---|---|---|
no parameters | {{Recipe}} |
an error |
product (or service) and building | {{Recipe|Crystalized Dew|Brickyard}} {{Recipe|product=Crystalized Dew|building=Brickyard}}
|
A table with exactly one row. |
product (or service) only | {{Recipe|Pie}} {{Recipe|product=Pie}}
|
A table with several rows, one for each building in which Pie can be produced. |
building only | {{Recipe||Market}} (note the double pipe) {{Recipe|building=Market}}
|
A table with several rows, one for each service provided by the Market. |
product (or service), but with output override | {{Recipe|Crystalized Dew|display=list}}
|
A short list of buildings and their efficiency stars that easily fit within another table:
|
Ingredients
Unlike when specifying the product (or service) and/or building, when you specify the ingredient, you explicitly must name the parameter with ingredient=
in the template. Currently, you cannot select both a product and an ingredient (for example, all recipes where Berries are the ingredient and Pie is the product), because this is redundant with the product parameter by itself (since there is currently only one arrangement of ingredients and options that will make a product).
The results of specifying the ingredient without also filtering on a building can display a long table. But on a resource's page, this information is expected to be valuable.
{{Recipe|ingredient=Wine}}
Yields:
Building | Grade | Ingredient #1 | Ingredient #2 | Product | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
★ 0:00 |
— |
|
1 Luxury | ||||||||||||||
|
★ 1:24 |
|
|
8 Scrolls | ||||||||||||||
|
★★ 1:24 |
|
|
8 Scrolls | ||||||||||||||
|
★★★ 1:03 |
|
|
8 Scrolls | ||||||||||||||
|
★ 0:42 |
— |
|
2 Pack of Luxury Goods | ||||||||||||||
|
★★ 0:42 |
— |
|
2 Pack of Luxury Goods | ||||||||||||||
|
★★★ 0:28 |
— |
|
2 Pack of Luxury Goods |
{{Recipe|building=Lumber Mill|ingredient=Wine}}
Yields:
Building | Grade | Ingredient #1 | Ingredient #2 | Product | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
★ 1:24 |
|
|
8 Scrolls |
Further Examples and Errors
The following are generated by calling the template as shown in the parameter examples table above.
1. product and building:
{{Recipe|Crystalized Dew|Brickyard}}
Yields:
Building | Grade | Ingredient #1 | Ingredient #2 | Ingredient #3 | Product | |||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
★ 0:42 |
|
|
|
2 |
2. product only
{{Recipe|Pie}}
Yields:
Building | Grade | Ingredient #1 | Ingredient #2 | Product | |||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
★ 2:06 |
|
|
10 | |||||||||||||||||
|
★★ 2:06 |
|
|
10 | |||||||||||||||||
|
★★★ 1:45 |
|
|
10 |
3. building only
{{Recipe|building=Market}}
Yields:
Building | Grade | Ingredient | Product | |||
---|---|---|---|---|---|---|
|
★ 0:00 |
|
1 Leisure | |||
|
★ 0:00 |
|
1 Treatment |
4. with the output override
{{Recipe|Crystalized Dew|display=list}}
Yields:
- Forester's Hut (★★)
- Alchemist's Hut (★★)
- Beanery (★)
- Brickyard (★)
5 with the output override but specifying a building
{{Recipe|building=Beanery|display=list}}
Yields:
- Porridge (★★★)
- Pickled Goods (★)
- Crystalized Dew (★)
The following are error states generated by calling the template incorrectly.
6. with no parameters
{{Recipe}}
Yields:
Lua error in Module:RecipeController at line 160: You must specify a product, building, or ingredient. Please see the template documentation for how to use the parameters.
7. using only one pipe and not specifying that the provided name is the building
{{Recipe|Scribe}}
Yields:
Lua error in Module:RecipeController at line 160: You must specify a product, building, or ingredient. Please see the template documentation for how to use the parameters.
8. asking for products or buildings with no recipes
{{Recipe|building=Small Warehouse}}
Yields:
No recipes. |
---|