Template:Infobox nutritional value: Difference between revisions
>Paul 012 Removing {{nowrap}} for user-input source, which could cause template to balloon excessively when multiple sources were entered. |
m 1 revision imported |
||
(One intermediate revision by one other user not shown) | |||
Line 42: | Line 42: | ||
| data1 = {{#if:{{{fat|}}} |<div style="position:relative;left:-0.65em;">{{{fat}}}</div> | | data1 = {{#if:{{{fat|}}} |<div style="position:relative;left:-0.65em;">{{{fat}}}</div> | ||
| {{#if:{{{satfat|}}}{{{transfat|}}}{{{monofat|}}}{{{polyfat|}}}{{{omega3fat|}}}{{{omega6fat|}}} | }} }} | | {{#if:{{{satfat|}}}{{{transfat|}}}{{{monofat|}}}{{{polyfat|}}}{{{omega3fat|}}}{{{omega6fat|}}} | }} }} | ||
| label2 = [[Saturated fat|Saturated]] | | label2 = [[Fatty acid]]s | ||
| | | label3 = [[Saturated fat|Saturated]] | ||
| | | data3 = {{{satfat|}}} | ||
| | | label4 = [[Trans fat|Trans]] | ||
| | | data4 = {{{transfat|}}} | ||
| | | label5 = [[Monounsaturated fat|Monounsaturated]] | ||
| | | data5 = {{{monofat|}}} | ||
| label6 = [[Polyunsaturated fat|Polyunsaturated]]<!-- | |||
-->{{#if:{{{omega3fat|}}} |<div style="padding-left:0.65em;padding-top:0.25em;font-weight:normal;">[[Omega-3 fatty acid|omega‑3]]</div>}}<!-- | -->{{#if:{{{omega3fat|}}} |<div style="padding-left:0.65em;padding-top:0.25em;font-weight:normal;">[[Omega-3 fatty acid|omega‑3]]</div>}}<!-- | ||
-->{{#if:{{{omega6fat|}}} |<div style="padding-left:0.65em;padding-top:0.25em;font-weight:normal;">[[Omega-6 fatty acid|omega‑6]]</div>}} | -->{{#if:{{{omega6fat|}}} |<div style="padding-left:0.65em;padding-top:0.25em;font-weight:normal;">[[Omega-6 fatty acid|omega‑6]]</div>}} | ||
| | | data6 = {{{polyfat|}}}<!-- | ||
-->{{#if:{{{omega3fat|}}} |<div style="padding-left:0.65em;padding-top:0.25em;">{{{omega3fat}}}</div>}}<!-- | -->{{#if:{{{omega3fat|}}} |<div style="padding-left:0.65em;padding-top:0.25em;">{{{omega3fat}}}</div>}}<!-- | ||
-->{{#if:{{{omega6fat|}}} |<div style="padding-left:0.65em;padding-top:0.25em;">{{{omega6fat}}}</div>}} | -->{{#if:{{{omega6fat|}}} |<div style="padding-left:0.65em;padding-top:0.25em;">{{{omega6fat}}}</div>}} | ||
Line 94: | Line 95: | ||
|datastyle=vertical-align:middle;padding-left:0.65em;line-height:1.1em; | |datastyle=vertical-align:middle;padding-left:0.65em;line-height:1.1em; | ||
| label1 = <b style="margin-left:-0.65em>[[Vitamin]]s</b> | | label1 = <b style="margin-left:-0.65em>[[Vitamin]]s</b> | ||
| data1 = '''Quantity''' {{right|{{abbr|'''%DV'''|Percentage of Daily Value}}<sup>†</sup>}} | | data1 = '''Quantity''' {{align|right|{{abbr|'''%DV'''|Percentage of Daily Value}}<sup>†</sup>}} | ||
| label2 = [[Vitamin A|Vitamin A equiv.]]<!-- | | label2 = [[Vitamin A|Vitamin A equiv.]]<!-- | ||
Line 116: | Line 117: | ||
| data6 = {{#if:{{{riboflavin_mg|}}} |{{align|right|{{#expr:{{{riboflavin_mg}}}/0.012 round 0}}%}} {{{riboflavin_mg}}} mg}} | | data6 = {{#if:{{{riboflavin_mg|}}} |{{align|right|{{#expr:{{{riboflavin_mg}}}/0.012 round 0}}%}} {{{riboflavin_mg}}} mg}} | ||
| label7 = [[Niacin|Niacin (B{{lower|0.35em|3}})]] | | label7 = [[Niacin (nutrient)|Niacin (B{{lower|0.35em|3}})]] | ||
| data7 = {{#if:{{{niacin_mg|}}} |{{align|right|{{#expr:{{{niacin_mg}}}/0.15 round 0}}%}} {{{niacin_mg}}} mg}} | | data7 = {{#if:{{{niacin_mg|}}} |{{align|right|{{#expr:{{{niacin_mg}}}/0.15 round 0}}%}} {{{niacin_mg}}} mg}} | ||
Line 161: | Line 162: | ||
|datastyle=vertical-align:middle;padding-left:0.65em;line-height:1.1em; | |datastyle=vertical-align:middle;padding-left:0.65em;line-height:1.1em; | ||
| label1 = <b style="margin-left:-0.65em>[[Mineral (nutrient)|Minerals]]</b> | | label1 = <b style="margin-left:-0.65em>[[Mineral (nutrient)|Minerals]]</b> | ||
| data1 = '''Quantity''' {{right|{{abbr|'''%DV'''|Percentage of Daily Value}}<sup>†</sup>}} | | data1 = '''Quantity''' {{align|right|{{abbr|'''%DV'''|Percentage of Daily Value}}<sup>†</sup>}} | ||
| label2 = [[Calcium in biology#Humans|Calcium]] | | label2 = [[Calcium in biology#Humans|Calcium]] | ||
Line 221: | Line 222: | ||
| <hr/><div class="wrap" style="padding:0.3em;line-height:1.2em;{{{belowstyle|}}}">{{{notes|}}}{{{note|}}}</div> }} | | <hr/><div class="wrap" style="padding:0.3em;line-height:1.2em;{{{belowstyle|}}}">{{{notes|}}}{{{note|}}}</div> }} | ||
| data31 = <div | | rowclass31=plainlist | ||
| data31 = <div style="background:#e0e0e0;padding:0.15em;line-height:1.25em;"> | |||
* Units | * Units | ||
* μg = [[microgram]]s{{•}}mg = [[milligram]]s | * μg = [[microgram]]s{{•}}mg = [[milligram]]s | ||
Line 229: | Line 231: | ||
| belowclass = wrap | | belowclass = wrap | ||
| belowstyle = background:#e0e0e0;padding:0.3em;line-height:1.5em;font-weight:normal; | | belowstyle = background:#e0e0e0;padding:0.3em;line-height:1.5em;font-weight:normal; | ||
| below = {{#ifexpr:{{#if:{{{noRDA|}}}|0|1}}+{{#if:{{{source|}}}{{{source_usda|}}}{{{source_USDA}}}|1|0}} |<!--(i.e. if noRDA hasn't been set and/or any of source/source_usda/source_USDA has/have been set, then:)-->{{#if:{{{noRDA|}}} | |<sup>†</sup>Percentages are roughly approximated using [[Dietary Reference Intake|US recommendations]] for adults.}} {{#if:{{{source_usda|}}}{{{source_USDA|}}} |<br/>{{nowrap|Source: [https://fdc.nal.usda.gov/index.html USDA | | below = {{#ifexpr:{{#if:{{{noRDA|}}}|0|1}}+{{#if:{{{source|}}}{{{source_usda|}}}{{{source_USDA}}}|1|0}} |<!--(i.e. if noRDA hasn't been set and/or any of source/source_usda/source_USDA has/have been set, then:)-->{{#if:{{{noRDA|}}} | |<sup>†</sup>Percentages are roughly approximated using [[Dietary Reference Intake|US recommendations]] for adults.}} {{#if:{{{source_usda|}}}{{{source_USDA|}}} |<br/>{{nowrap|Source: [https://fdc.nal.usda.gov/index.html USDA FoodData Central]}} | {{#if:{{{source|}}} | <br/>Source: {{{source}}} }} }} }} | ||
}}<noinclude>{{documentation}}</noinclude> | }}{{#invoke:Check for unknown parameters|check|unknown={{main other|[[Category:Pages using infobox nutritional value with unknown parameters|_VALUE_{{PAGENAME}}]]}}|preview=Page using [[Template:Infobox nutritional value]] with unknown parameter "_VALUE_"|ignoreblank=y| alanine | alcohol | arginine | aspartic acid | belowstyle | betacarotene_ug | caffeine | calcium_mg | caption | carbs | cholesterol | choline_mg | copper_mg | cystine | fat | fiber | fibre | float | folate_ug | glutamic acid | glycine | histidine | hydroxyproline | image | image_alt | image_size | iron_mg | isoleucine | kcal | kJ | lactose | leucine | lutein_ug | lysine | magnesium_mg | manganese_mg | methionine | monofat | name | niacin_mg | noRDA | note | notes | omega3fat | omega6fat | opt1n | opt1v | opt2n | opt2v | opt3n | opt3v | opt4n | opt4v | pantothenic_mg | phenylalanine | phosphorus_mg | polyfat | potassium_mg | proline | protein | riboflavin_mg | satfat | selenium_ug | serine | serving_size | sodium_mg | source | source_usda | source_USDA | starch | sugars | thiamin_mg | threonine | transfat | tryptophan | tyrosine | valine | vitA_asbeta_iu | vitA_iu | vitA_ug | vitB6_mg | vitB12_ug | vitC_mg | vitD_iu | vitD_ug | vitE_iu | vitE_mg | vitK_ug | water | zinc_mg }}<noinclude>{{documentation}}</noinclude> |
Latest revision as of 18:25, 29 June 2023
| |
†Percentages are roughly approximated using US recommendations for adults. |
This template uses Lua: |
This template employs intricate features of template syntax.
You are encouraged to familiarise yourself with its setup and parser functions before editing the template. If your edit causes unexpected problems, please undo it quickly, as this template may appear on a large number of pages. You can conduct experiments, and should test all major changes, in either this template's sandbox, the general template sandbox, or your user space before changing anything here. |
This is the {{infobox nutritional value}} template.
Basic usage
{{Infobox nutritional value
| name =
| kJ =
| carbs =
| fat =
| protein =
| note =
}}
Parameters
- Required fields: name, kJ, carbs, fat, protein. You must state the units of measurement that are being used, except for kJ, which is in kilojoules (1 Calorie = 1 kcal = 4.2 kJ). The units are usually expressed in grams (g), for example:
|fat=3 g
.- Note: To specify energy in kcal rather than kJ, use kcal instead.
- Optional fields: image, caption, serving_size, sugars, lactose, satfat, transfat, monofat, polyfat, omega3fat, omega6fat, fibre, starch, water, cholesterol, alcohol and caffeine. Again, you must state the units that are being used.
- Contributor defined fields: Additional fields can be added using the opt1n and opt1v fields, where n is for name and v is for value. Up to four optional fields are supported, opt1n & opt1v up to opt4n & opt4v.
- The following optional variables are converted into percentages of RDA (taken as averages for males and females aged 25–50 years from the USDA 2000 recommendation)
- Minerals (in mg) - calcium_mg, copper_mg, iron_mg, phosphorus_mg, magnesium_mg, manganese_mg, selenium_ug, sodium_mg, potassium_mg, zinc_mg. Write the number without the unit.
- Vitamins (in mg, μg, or international units) - vitA_ug, vitA_iu (in IU), vitA_asbeta_iu (in IU), betacarotene_ug (subcategory of vitamin A!), thiamin_mg (vit. B1), riboflavin_mg (vit. B2), niacin_mg (vit. B3), pantothenic_mg (pantothenic acid), vitB6_mg, folate_ug, vitB12_ug, choline_mg, vitC_mg, vitD_ug, vitD_iu (in IU), vitE_mg, vitE_iu, vitK_ug. Write the number without the unit.
- Other optional variables and flags
- note - a convenient way to indicate serving sizes or edible parts, e.g., 1 banana is 100 to 150 g or other information.
- source - sets the data source of the information used in the template.
- source_usda - a 1 in this field will automatically set the source as the USDA database.
- noRDA - optional suppression of RDA message: noRDA=1
- float -
|float=left
will cause the table to appear on the left side of the article,|float=center
for centered, and|float=none
to place it on the left, but without wrapping text around it. The default is|float=right
.
- Additional notes
- According to SI rules, there should be a non-breaking space between the number and the unit: "14 g" (which displays as "14 g") and not "14g".
- Don't specify numbers in too many decimals.
- Splitting up components that are present in trace amounts is not very meaningful (e.g. 1.5 g fats of which 0.5 g unsaturated).
- Only vitamins and minerals for which this product is considered to be a good source should be included, in order to prevent clogging up the article with a huge table.
Nutritional values can be found in the USDA's FoodData Central (formerly National Nutrient Database). Note that fibres are counted as carbohydrates. Note also that the calculated energy value given in the USDA database sometimes includes 4 kcal per gram of fibre, which is not really correct, and it would be better for Wikipedia articles to exclude the fibre from the energy value. (The USDA documentation says, "For multi-ingredient processed foods, kilocalorie values (source codes 8 or 9; ...) generally reflect industry practices (as permitted by NLEA) of calculating kilocalories as 4, 4, or 9 kilocalories per gram of protein, carbohydrate, and fat, respectively, or as 4, 4, or 9 kilocalories per gram of protein, carbohydrate minus insoluble fiber, and fat. The latter method is often used for high-fiber foods.")
Full syntax
{{Infobox nutritional value
| name =
| image = <!-- Filename is enough -->
| image_size = <!-- Defaults to 235px -->
| image_alt =
| caption =
| serving_size =
| kJ =
| carbs =
| starch =
| sugars =
| lactose =
| fibre = <!-- or |fiber= -->
| fat =
| satfat =
| transfat =
| monofat =
| polyfat =
| omega3fat =
| omega6fat =
| protein =
| tryptophan =
| threonine =
| isoleucine =
| leucine =
| lysine =
| methionine =
| cystine =
| phenylalanine =
| tyrosine =
| valine =
| arginine =
| histidine =
| alanine =
| aspartic acid =
| glutamic acid =
| glycine =
| proline =
| serine =
| hydroxyproline =
| water =
| cholesterol =
| alcohol =
| caffeine =
| vitA_ug =
| vitA_iu =
| betacarotene_ug =
| lutein_ug =
| thiamin_mg =
| riboflavin_mg =
| niacin_mg =
| pantothenic_mg =
| vitB6_mg =
| folate_ug =
| vitB12_ug =
| choline_mg =
| vitC_mg =
| vitD_ug =
| vitD_iu =
| vitE_mg =
| vitK_ug =
| calcium_mg =
| copper_mg =
| iron_mg =
| magnesium_mg =
| manganese_mg =
| phosphorus_mg =
| potassium_mg =
| selenium_ug =
| sodium_mg =
| zinc_mg =
| opt1n =
| opt1v =
| opt2n =
| opt2v =
| opt3n =
| opt3v =
| opt4n =
| opt4v =
| note =
| source =
| source_usda =
| noRDA =
| float =
}}
Examples
Nutritional value per 100 g (3.5 oz) | |
---|---|
Energy | 2,450 kJ (590 kcal) |
22 g | |
Starch | 8 g |
Sugars | 5 g 1 g |
Dietary fibre | 9 g |
50 g | |
Saturated | 7 g |
Trans | 3 g |
Monounsaturated | 25 g |
Polyunsaturated | 16 g 1 g 2 g |
24 g | |
Tryptophan | 70 mg |
Threonine | 490 mg |
Isoleucine | 570 mg |
Leucine | 920 mg |
Lysine | 690 mg |
Methionine | 200 mg |
Cystine | 230 mg |
Phenylalanine | 610 mg |
Tyrosine | 380 mg |
Valine | 750 mg |
Arginine | 890 mg |
Histidine | 250 mg |
Alanine | 640 mg |
Aspartic acid | 2.850 g |
Glutamic acid | 2.260 g |
Glycine | 780 mg |
Proline | 2.310 g |
Serine | 610 mg |
Hydroxyproline | 0 mg |
Vitamins | Quantity %DV† |
Vitamin A equiv. | 2% 12 μg1% 120 μg |
Thiamine (B1) | 87% 1 mg |
Riboflavin (B2) | 167% 2 mg |
Niacin (B3) | 3% 0.5 mg |
Pantothenic acid (B5) | 2% 0.1 mg |
Vitamin B6 | 77% 1 mg |
Folate (B9) | 0% 1.5 μg |
Vitamin B12 | 21% 0.5 μg |
Vitamin C | 24% 20 mg |
Vitamin D | 67% 10 μg |
Vitamin E | 33% 5 mg |
Vitamin K | 10% 10 μg |
Minerals | Quantity %DV† |
Calcium | 20% 200 mg |
Copper | 45% 0.9 mg |
Iron | 38% 5 mg |
Magnesium | 0% 1.2 mg |
Manganese | 57% 1.2 mg |
Phosphorus | 7% 50 mg |
Potassium | 2% 80 mg |
Selenium | 33% 23 μg |
Sodium | 3% 40 mg |
Zinc | 4% 0.4 mg |
Other constituents | Quantity |
Water | 5 g |
Alcohol (ethanol) | 1 g |
Caffeine | 20 mg |
Cholesterol | 2 mg |
Footnote text here | |
| |
†Percentages are roughly approximated using US recommendations for adults. Source: USDA FoodData Central |
{{Infobox nutritional value
| name = Foonuts
| kJ = 2450
| carbs = 22 g
| starch = 8 g
| sugars = 5 g
| lactose = 1 g
| fibre = 9 g
| fat = 50 g
| satfat = 7 g
| transfat = 3 g
| monofat = 25 g
| polyfat = 16 g
| omega3fat = 1 g
| omega6fat = 2 g
| protein = 24 g
| tryptophan = 70 mg
| threonine = 490 mg
| isoleucine = 570 mg
| leucine = 920 mg
| lysine = 690 mg
| methionine = 200 mg
| cystine = 230 mg
| phenylalanine = 610 mg
| tyrosine = 380 mg
| valine = 750 mg
| arginine = 890 mg
| histidine = 250 mg
| alanine = 640 mg
| aspartic acid = 2.850 g
| glutamic acid = 2.260 g
| glycine = 780 mg
| proline = 2.310 g
| serine = 610 mg
| hydroxyproline = 0 mg
| water = 5 g
| cholesterol = 2 mg
| alcohol = 1 g
| caffeine = 20 mg
| vitA_ug = 12
| betacarotene_ug = 120
| thiamin_mg = 1
| riboflavin_mg = 2
| niacin_mg = 0.5
| pantothenic_mg = 0.1
| vitB6_mg = 1
| folate_ug = 1.5
| vitB12_ug = 0.5
| vitC_mg = 20
| vitD_ug = 10
| vitE_mg = 5
| vitK_ug = 10
| calcium_mg = 200
| copper_mg = 0.9
| iron_mg = 5
| magnesium_mg = 1.2
| manganese_mg = 1.2
| phosphorus_mg = 50
| potassium_mg = 80
| sodium_mg = 40
| selenium_ug = 23
| zinc_mg = 0.4
| note = Footnote text here
| source_usda = 1
| float =
}}
will generate →
Translations
If you translate this template for use in other language Wikipedias, you could consider keeping the English variable names, so that you can simply copy/paste existing tables from English to your language (and back). Or you could make two versions, one using native-language variable names, and the other using the English names.
TemplateData
TemplateData for Infobox nutritional value
A template for recording the nutritional value of foods
Parameter | Description | Type | Status | |
---|---|---|---|---|
name | name | The name of the food | Unknown | required |
kJ | kJ | no description | Unknown | suggested |
carbs | carbs | Total carbohydrates per 100 grams of food. State the unit being used (usually g for grams). | Unknown | required |
fat | fat | Total fat per 100 grams of food. State the unit being used (usually g for grams). | Unknown | required |
protein | protein | Total protein per 100 grams of food. State the unit being used (usually g for grams). | Unknown | required |
note | note | Any explanatory notes, e.g., which parts of the vegetable are edible | Unknown | optional |
float | float | no description | Unknown | optional |
image | image | no description | Unknown | optional |
image_size | image_size | no description | Unknown | optional |
image_alt | image_alt | no description | Unknown | optional |
caption | caption | no description | Unknown | optional |
serving_size | serving_size | no description | Unknown | optional |
kcal | kcal | no description | Unknown | optional |
starch | starch | no description | Unknown | optional |
sugars | sugars | no description | Unknown | optional |
lactose | lactose | no description | Unknown | optional |
fiber | fiber | no description | Unknown | optional |
fibre | fibre | no description | Unknown | optional |
satfat | satfat | no description | Unknown | optional |
transfat | transfat | no description | Unknown | optional |
monofat | monofat | no description | Unknown | optional |
polyfat | polyfat | no description | Unknown | optional |
omega3fat | omega3fat | no description | Unknown | optional |
omega6fat | omega6fat | no description | Unknown | optional |
tryptophan | tryptophan | no description | Unknown | optional |
threonine | threonine | no description | Unknown | optional |
isoleucine | isoleucine | no description | Unknown | optional |
leucine | leucine | no description | Unknown | optional |
lysine | lysine | no description | Unknown | optional |
methionine | methionine | no description | Unknown | optional |
cystine | cystine | no description | Unknown | optional |
phenylalanine | phenylalanine | no description | Unknown | optional |
tyrosine | tyrosine | no description | Unknown | optional |
valine | valine | no description | Unknown | optional |
arginine | arginine | no description | Unknown | optional |
histidine | histidine | no description | Unknown | optional |
alanine | alanine | no description | Unknown | optional |
aspartic acid | aspartic acid | no description | Unknown | optional |
glutamic acid | glutamic acid | no description | Unknown | optional |
glycine | glycine | no description | Unknown | optional |
proline | proline | no description | Unknown | optional |
serine | serine | no description | Unknown | optional |
hydroxyproline | hydroxyproline | no description | Unknown | optional |
vitA_ug | vitA_ug | no description | Unknown | optional |
betacarotene_ug | betacarotene_ug | no description | Unknown | optional |
lutein_ug | lutein_ug | no description | Unknown | optional |
vitA_iu | vitA_iu | no description | Unknown | optional |
vitA_asbeta_iu | vitA_asbeta_iu | no description | Unknown | optional |
thiamin_mg | thiamin_mg | no description | Unknown | optional |
riboflavin_mg | riboflavin_mg | no description | Unknown | optional |
niacin_mg | niacin_mg | no description | Unknown | optional |
pantothenic_mg | pantothenic_mg | no description | Unknown | optional |
vitB6_mg | vitB6_mg | no description | Unknown | optional |
folate_ug | folate_ug | no description | Unknown | optional |
vitB12_ug | vitB12_ug | no description | Unknown | optional |
choline_mg | choline_mg | no description | Unknown | optional |
vitC_mg | vitC_mg | no description | Unknown | optional |
vitD_ug | vitD_ug | no description | Unknown | optional |
vitD_iu | vitD_iu | no description | Unknown | optional |
vitE_mg | vitE_mg | no description | Unknown | optional |
vitE_iu | vitE_iu | no description | Unknown | optional |
vitK_ug | vitK_ug | no description | Unknown | optional |
calcium_mg | calcium_mg | no description | Unknown | optional |
iron_mg | iron_mg | no description | Unknown | optional |
magnesium_mg | magnesium_mg | no description | Unknown | optional |
manganese_mg | manganese_mg | no description | Unknown | optional |
phosphorus_mg | phosphorus_mg | no description | Unknown | optional |
potassium_mg | potassium_mg | no description | Unknown | optional |
sodium_mg | sodium_mg | no description | Unknown | optional |
zinc_mg | zinc_mg | no description | Unknown | optional |
copper_mg | copper_mg | no description | Unknown | optional |
selenium_ug | selenium_ug | no description | Unknown | optional |
water | water | no description | Unknown | optional |
alcohol | alcohol | no description | Unknown | optional |
caffeine | caffeine | no description | Unknown | optional |
cholesterol | cholesterol | no description | Unknown | optional |
opt1v | opt1v | no description | Unknown | optional |
opt2v | opt2v | no description | Unknown | optional |
opt3v | opt3v | no description | Unknown | optional |
opt4v | opt4v | no description | Unknown | optional |
opt1n | opt1n | no description | Unknown | optional |
opt2n | opt2n | no description | Unknown | optional |
opt3n | opt3n | no description | Unknown | optional |
opt4n | opt4n | no description | Unknown | optional |
notes | notes | no description | Unknown | optional |
belowstyle | belowstyle | no description | Unknown | optional |
noRDA | noRDA | no description | Unknown | optional |
source | source | no description | Unknown | optional |
source_usda | source_usda | no description | Unknown | optional |