# Templates are used to display an object in HTML

import DocumentTemplate

class Food:
    "Something edible"
    def __init__(self,name,calories):
        self.name=name
        self.calories=calories
	
    def is_fattening(self):
        if self.calories > 100:
            return 1

    index_html=DocumentTemplate.HTML("""\
<html>
<p>Food: <!--#var name--></p>
<p>Calories: <!--#var calories--></p>
<!--#if is_fattening-->
<p><blink>Warning: Do Not Eat!</blink></p>
<!--#/if-->
</html>""")

# create a Food object, spam
spam=Food("SPAM",250)

# display it with its template
print spam.index_html(spam)