Hi All,

I'm having an issue with chameleon.zpt templates and macros.  I've
create two templates, one with a macro and slots and one that is used to
fill the slots in my main template.  Both templates have an xml and
DOCTYPE declaration.  The issue is that the final rendered page ends up
having two xml declarations and two DOCTYPE declarations.

I can fix my rendered page by removing the declarations, but if I want
to develop the individual templates further and validate as I go I need
re-add the declarations.

I put together a simple bfg app (
) that demonstrates this issue including a test.  Here is my test, it
seems to be a little more complicated than I expected compared to
testing views without macros.  Am I doing this in a good way or is there
a better method?

    def test_my_view_renderer(self):
        from chameleon_zpt_test.views import my_view
        context = testing.DummyModel()
        request = testing.DummyRequest()
        info = my_view(context, request)
        from repoze.bfg.chameleon_zpt import renderer_factory
=renderer_factory('chameleon_zpt_test:templates/mytemplate.pt', level=3)
        from repoze.bfg.view import rendered_response
        from chameleon_zpt_test.views import my_view
        response = my_view(context, request)
        result = renderer(response{'context':context,'request':request})
        self.assertEqual(result.count('<?xml version='),1)
        self.assertEqual(result.count('<!DOCTYPE html'),1)

Repoze-dev mailing list

Reply via email to