Mercurial > piecrust2
changeset 429:ca5a3c970263
templating: Workaround for a bug with Pystache.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Sat, 27 Jun 2015 00:03:56 -0700 |
parents | f4b7c8f183a4 |
children | 21e26ed867b6 |
files | piecrust/templating/pystacheengine.py |
diffstat | 1 files changed, 21 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/piecrust/templating/pystacheengine.py Fri Jun 26 23:19:55 2015 -0700 +++ b/piecrust/templating/pystacheengine.py Sat Jun 27 00:03:56 2015 -0700 @@ -53,6 +53,26 @@ if self.renderer: return - self.renderer = pystache.Renderer( + self.renderer = _WorkaroundRenderer( search_dirs=self.app.templates_dirs) + +_knowns = ['PieCrustData', 'LazyPageConfigData', 'Paginator', 'Assetor', + 'PageLinkerData'] + + +class _WorkaroundRenderer(pystache.Renderer): + def _make_resolve_context(self): + mrc = super(_WorkaroundRenderer, self)._make_resolve_context() + + def _workaround(stack, name): + # Pystache will treat anything that's not a string or a dict as + # a list. This is just plain wrong, but it will take a while before + # the project can get patches on Pypi. + res = mrc(stack, name) + if res is not None and res.__class__.__name__ in _knowns: + res = [res] + return res + + return _workaround +