Just like when you add new foods, you can write
recipes in Pantry by using the Pantry XML file. While
you enter foods in Pantry XML files by using the
foods
element, to enter recipes you
use the recipe
element.
To create a Pantry XML file, start your favorite text
editor and open a text file. For the purposes of our
example we'll use pantry.xml
,
though you can create any filename that ends with
.xml
.
As we saw earlier when we created new foods, the
root element of a Pantry XML file is
pantry
. Each recipe is contained
in a recipe
element. The
recipe
elemen thas the same
attributes as the food
element
that we learned about earlier:
Of all these attributes, you are required to
set only the unit
and
qty
attributes. You can leave
as many of the other ones out as you wish,
though ordinarily you will set the
name
and
group
attributes while
leaving many of the others blank.
Just like when you create a new food using the
food
element, you must set the
unit
attribute to one of the
available units for the recipe. Pantry will
automatically create the g
,
oz
, and
lb
units for you. You can
also have Pantry create a
serving
unit, as we will
discuss shortly.
For our example, we will create a recipe with the
name Easy Corn Bread
. As you
will see, the new recipe has its unit set to
serving
; shortly we will see
exactly how this works. You will also notice that
many of the attributes for the various traits, such
as date
and
meal
, are not set at all; Pantry
will set such traits to the empty string.
Example 7.1. Creating the recipe
element
<pantry> <recipe name="Easy Corn Bread" group="Baked Products" pctRefuse='' refDesc='' qty='1' unit='serving'> </recipe> </pantry>
Next you will need to set the yield of your
recipe. The yield
element has
three attributes: grams
,
servings
, and
text
. The
servings
attribute is easiest to
understand, so we will discuss it first.
Often when you make a recipe, you split it
into an even number of servings. If that is the
case for your recipe, you may enter an
appropriate value for the
servings
attribute. Pantry
will automatically create a
serving
available unit
for the food in this case. If you do not wish to
specify a number of servings, you can simply not
use the servings
attribute at
all.
For our corn bread example, we will say that the recipe makes nine servings.
In order for Pantry to accurately calculate the nutrient content of a particular amount of food, it needs to know what the total mass of your completed recipe is, after it has been fully prepared (that is, after cooking, baking, mixing, etc., as the case may be.)
Pantry can "guess" what the total
mass of your completed recipe is. Pantry guesses
by adding up the mass of all the ingredients you
entered for the recipe. To have Pantry guess
for you, simply use an empty string for the
grams
attribute, or just
leave the grams
attribute out
entirely. However, you will often find that the
completed recipe weighs significantly less than
the mass of all the ingredients. This is because
a lot of water often evaporates as you cook or
bake foods. Thus, for the most accurate
results, you may enter the mass of your
completed recipe so that Pantry may take it into
account. To do this, enter the appropriate value
(in grams) for the grams
attribute.
However, if you have entered a
servings
attribute, and you
will use only the
serving
available unit
when you use the recipe, then entering a
grams
attribute will do you
no good. This is because Pantry will calculate
each serving so that it is the appropriate
fraction of the total, but the actual total mass
will not matter.
I always cut my cornbread into nine neat
squares, and I always eat only one square at a
time. Thus, since I will use only the
servings
available unit
for the corn bread, I will simply enter an empty
string for the grams
attribute.
Finally, you may enter any text you wish
for the text
attribute.
This text can
be used to describe the yield of the recipe.
I make my corn bread in a 8x8-inch dish, so
I will make an appropriate entry for the
yield
element.
No recipe is complete without ingredients. Each
single ingredient is represented by a
ingredient
element. The
ingredient
element has four
attributes: name
,
qty
, unit
,
comment
, and
file
.
As you will recall, each ingredient in a Pantry
recipe is a another Pantry food. These foods come
from another Pantry file. For each ingredient, you
will specify the source file by specifying the path
to the file in the file
attribute. If you have specified a search path in
your pantryrc.xml
file, you
need not specify the entire path if the source file
is in the search path you specified. Otherwise,
specify the entire path of the file for each
file
attribute.
For each ingredient, Pantry will look in the file
specified for the food you specify using the
name
attribute. Unlike much of
the rest of Pantry, the text of the
name
attribute is not a regular
expression. Instead, you must exactly match every
space, and you must exactly match the mixture of
upper- and lower-case letters, as well.
The qty
attribute is simply
the quantity of the ingredient. As with most other
numeric values in Pantry, you may use an integer, a
floating-point number, a fraction, or even a mixed
number.
The unit
attribute is
an exact match of the available unit you wish to use
for this ingredient. As with the
name
attribute, this is
case-sensitive.
Finally, the last attribute,
comment
, is optional. This can be
whatever helpful text you may wish to enter.
Here is our corn bread example, complete with all
its ingredients. Because I have set up a
.pantryrc.xml
file with a path
that includes the master
file,
I don't need to give the entire path for the
path
attributes.
Example 7.3. A recipe with its
ingredients
<pantry> <recipe name="Easy Corn Bread" group="Baked Products" pctRefuse='' refDesc='' qty='1' unit='serving'> <yield grams='' servings='9' text='One square pan' /> <ingredient name='Wheat flour, white, all-purpose, enriched, unbleached' qty='1 1/4' unit='cup' comment='' file='master' /> <ingredient name='Cornmeal, whole-grain, yellow' qty='3/4' unit='cup' comment='' file='master' /> <ingredient name='Sugars, granulated' qty='1/4' unit='cup' comment='' file='master' /> <ingredient name='Leavening agents, baking powder, double-acting, straight phosphate' qty='2' unit='tsp' comment='' file='master' /> <ingredient name='Salt, table' qty='1/2' unit='tsp' comment='' file='master' /> <ingredient name='Milk, reduced fat, fluid, 2% milkfat, with added vitamin A' qty='1' unit='cup' comment='' file='master' /> <ingredient name='Oil, canola and soybean' qty='1/4' unit='cup' comment='' file='master' /> <ingredient name='Egg, whole, raw, fresh' qty='1' unit='large' comment='' file='master' /> </recipe> </pantry>
Finally, you may create additional available
units for the food. Pantry automatically creates the
g
, oz
,
and lb
units for you; in
addition, if you specified a
servings
attribute to the
yield
element, as we discussed
above, then Pantry will also automatically create a
serving
available unit. If
you wish to create any additional available units,
you will need to know the weight (in grams) of that
unit. If for instance you are entering a recipe for
cookies and you want to create an avaiable unit for
one cookie, you'll need to know the weight in grams
of one cookie.
To create available units, create one or more
unit
elements. Each
unit
element will have both
name
and grams
attributes. As I stated above, I always eat one
serving of corn bread, so I do not have any use for
the units
element here. However,
for the sake of illustration, we'll say that a
large piece
of corn bread
weighs 70 grams.
Example 7.4. A recipe's units
<pantry> <recipe name="Easy Corn Bread" group="Baked Products" pctRefuse='' refDesc='' qty='1' unit='serving'> <yield grams='' servings='9' text='One square pan' /> <ingredient name='Wheat flour, white, all-purpose, enriched, unbleached' qty='1 1/4' unit='cup' comment='' file='master' /> <ingredient name='Cornmeal, whole-grain, yellow' qty='3/4' unit='cup' comment='' file='master' /> <ingredient name='Sugars, granulated' qty='1/4' unit='cup' comment='' file='master' /> <ingredient name='Leavening agents, baking powder, double-acting, straight phosphate' qty='2' unit='tsp' comment='' file='master' /> <ingredient name='Salt, table' qty='1/2' unit='tsp' comment='' file='master' /> <ingredient name='Milk, reduced fat, fluid, 2% milkfat, with added vitamin A' qty='1' unit='cup' comment='' file='master' /> <ingredient name='Oil, canola and soybean' qty='1/4' unit='cup' comment='' file='master' /> <ingredient name='Egg, whole, raw, fresh' qty='1' unit='large' comment='' file='master' /> <unit name='large piece' grams='70' /> </recipe> </pantry>
Finally, you need something to tell you how to
put together all those ingredients. You can do this
by including an optional directions
element. Enclose each paragraph of your directions
inside a p
element. Eventually I
will probably add additional formatting tags, such
as b
and i
,
but for now you're stuck with just
p
.
Example 7.5. Recipe directions
<pantry> <recipe name="Easy Corn Bread" group="Baked Products" pctRefuse='' refDesc='' qty='1' unit='serving'> <yield grams='' servings='9' text='One square pan' /> <ingredient name='Wheat flour, white, all-purpose, enriched, unbleached' qty='1 1/4' unit='cup' comment='' file='master' /> <ingredient name='Cornmeal, whole-grain, yellow' qty='3/4' unit='cup' comment='' file='master' /> <ingredient name='Sugars, granulated' qty='1/4' unit='cup' comment='' file='master' /> <ingredient name='Leavening agents, baking powder, double-acting, straight phosphate' qty='2' unit='tsp' comment='' file='master' /> <ingredient name='Salt, table' qty='1/2' unit='tsp' comment='' file='master' /> <ingredient name='Milk, reduced fat, fluid, 2% milkfat, with added vitamin A' qty='1' unit='cup' comment='' file='master' /> <ingredient name='Oil, canola and soybean' qty='1/4' unit='cup' comment='' file='master' /> <ingredient name='Egg, whole, raw, fresh' qty='1' unit='large' comment='' file='master' /> <unit name='large piece' grams='70' /> <directions> <p> Heat oven to 400 degrees F. Grease 8 or 9-inch pan. Combine dry ingredients. Stir in milk, oil, and egg, mixing just until dry ingredients are moistened. Pour batter into prepared pan. Bake 20 to 25 minutes or until light golden brown and wooden pick inserted in center comes out clean. Serve warm. </p> </directions> </recipe> </pantry>