import kid, time

def dump_tmpl(tname, tmpl_obj):
    tmpl = tmpl_obj.serialize()
    fp = open(tname + '.html', 'w'); fp.write(tmpl); fp.close() 
    print tmpl; print

fruits = ["mango", "boisenberry", "orange", "apple", "M&M"]

# ----------------

tn = 'tmpl_ex1'
template = kid.Template(file=tn + '.kid',       # master template
                        title="Example #1",
                        fruits=fruits,
                        items='',
                        ts=time.localtime(),
                        message="Gear up!",
                        )

dump_tmpl(tn, template)

# ----------------

tech_ratings = {'PHP'  : 'Too soft',
                'XSLT' : 'Too hard',
                'Kid'  : 'Just right!',
                }

tn = 'tmpl_ex2'
template = kid.Template(file=tn + '.kid',       # child template
                        title="I am Example 2",
                        fruits=fruits,
                        ts=time.localtime(),
                        message="Gear up, again!",
                        rating_map=tech_ratings, # set the "mapping" dict
                        )

dump_tmpl(tn, template)
