Mercurial > piecrust2
view piecrust/sources/array.py @ 912:cd236a6af9f6
data: Add access to route metadata in the templating data.
It's available under `route`.
Also, rename `slug` to `rel_url`, because it's confusing when `slug` could
be the route metadata of the same name as provided by the default page source.
The old `slug` is still there for backwards compatibility though.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Fri, 28 Apr 2017 10:05:14 -0700 |
parents | ab5c6a8ae90a |
children |
line wrap: on
line source
from piecrust.sources.base import PageSource from piecrust.sources.mixins import SimplePaginationSourceMixin from piecrust.sources.pageref import PageRef class CachedPageFactory(object): """ A `PageFactory` (in appearance) that already has a page built. """ def __init__(self, page): self._page = page @property def rel_path(self): return self._page.rel_path @property def metadata(self): return self._page.source_metadata @property def ref_spec(self): return self._page.ref_spec @property def path(self): return self._page.path def buildPage(self): return self._page class ArraySource(PageSource, SimplePaginationSourceMixin): def __init__(self, app, inner_source, name='array', config=None): super(ArraySource, self).__init__(app, name, config) self.inner_source = inner_source @property def page_count(self): return len(self.inner_source) def getPageFactories(self): for p in self.inner_source: yield CachedPageFactory(p)