Skip to content
Browse files

Add page.date and page.time template variables. Closes #14

  • Loading branch information...
1 parent d3177a1 commit 19a78ad171f4e3d28395faa05a44983d6e49cb06 @mythmon committed Aug 27, 2011
Showing with 14 additions and 9 deletions.
  1. +14 −9 wok/page.py
View
23 wok/page.py
@@ -64,15 +64,17 @@ def build_meta(self):
"""
Ensures the guarantees about metadata for documents are valid.
- `page.title` - will exist and will be a string.
- `page.slug` - will exist and will be a string.
- `page.author` - will exist, and contain fields `name` and `email`.
- `page.category` - will be a list.
- `page.published` - will exist.
- `page.datetime` - will be a datetime.
- `page.tags` - will be a list.
- `page.url` - will be the url of the page, relative to the web root.
- `page.subpages` - will be a list containing every sub page of this page
+ `page.title` - Will exist and will be a string.
+ `page.slug` - Will exist and will be a string.
+ `page.author` - Will exist, and contain fields `name` and `email`.
+ `page.category` - Will be a list.
+ `page.published` - Will exist.
+ `page.datetime` - Will be a datetime.
+ `page.date` - Will be a date
+ `page.time` - Will be a time
+ `page.tags` - Will be a list.
+ `page.url` - Will be the url of the page, relative to the web root.
+ `page.subpages` - Will be a list containing every sub page of this page
"""
if not self.meta:
@@ -121,6 +123,9 @@ def build_meta(self):
self.meta['datetime'] = self.meta[name]
if not 'datetime' in self.meta:
self.meta['datetime'] = datetime.now()
+ # date
+ self.meta['date'] = self.meta['datetime'].date()
+ self.meta['time'] = self.meta['datetime'].time()
# tags
if not 'tags' in self.meta:

0 comments on commit 19a78ad

Please sign in to comment.
Something went wrong with that request. Please try again.