I just want a way to have parameterizable re-usable blocks of html. However, these "blocks" must be python object (I want to store them in the ZODB, so it must not be macros, which are ZPT-only dialect), they will reference template files, of course. I tried using ViewPageTemplateFile this way: blocks = [ViewPageTemplateFile('templates/block.pt'),ViewPageTemplateFile('templates/block_another.pt')] then, in my view class I have a method: def renderHTMLWidgets(self): for wdgt in self.blocks return wdgt.__call__(self.context,self.request) in the template file:
It works, the html is rendered, the ZPT is evaluated first. Cool. However, I didn't find a way to do something like: vars = {text:"Hello World"} blocks = [ViewPageTemplateFile('templates/block.pt',vars)] In other words, pass vars to the template. This would work pretty much the same way Rails' partials work. It would be a light alternative to viewlets - wouldn't require any ZCML registration and would allow to create more general HTML widgets. What I would like to know is how would be the best way to pass vars to the template? Should I create a subclass of ViewPageTemplateFile? Is there already something like this "partial" thing in Plone/Zope 2/Zope 3?