# note that when the sapt package is in your PYTHONPATH, the following
# imports can be replaced with 'from sapt import *'
from zope.pagetemplate.pagetemplate import PageTemplate
from zope.tales.engine import Engine

p = PageTemplate()
p.pt_edit('<html><body tal:content="foo" /></html>', None)

context = {'foo': 'bar'}
context.update(Engine.getBaseNames())

print p.pt_render(context)

m = PageTemplate()
m.pt_edit(('<html>'
            '<body metal:define-macro="foo">'
            '<div style="background-color: green">'
            '<div metal:define-slot="bar">baz</div>'
            '</div>'
            '</body>'
            '</html>'), None)

context['m'] = m
p2 = PageTemplate()
p2.pt_edit(('<html>'
            '<body metal:use-macro="m/macros/foo">'
            '<div metal:fill-slot="bar">green</div>'
            '</body>'
            '</html>'), None)
print p2.pt_render(context)

p3 = PageTemplate()
p3.pt_edit(('<html>'
            '<body>'
            '<div tal:define="foo string:bar">'
            '<div tal:condition="not: python: foo == \'baz\'">foo != baz</div>'
            '</div>'
            '<tal:block content="python:foo"></tal:block>'
            '</body>'
            '</html>'), None)
print p3.pt_render(context)

