1
Fork 0

Add date format template filter

This commit is contained in:
Jake Howard 2016-05-27 15:42:29 +01:00
parent 093c6042f0
commit 636600f034
Signed by: jake
GPG key ID: 57AFB45680EDD477
4 changed files with 12 additions and 3 deletions

View file

@ -35,8 +35,7 @@ SOCIAL = social.generate()
DEFAULT_PAGINATION = False DEFAULT_PAGINATION = False
DELETE_OUTPUT_DIRECTORY = True DELETE_OUTPUT_DIRECTORY = True
DEFAULT_DATE_FORMAT = '%c'
DEFAULT_DATE = "fs"
PAGE_PATHS = ["pages"] PAGE_PATHS = ["pages"]
PAGE_SAVE_AS = "{slug}/index.html" PAGE_SAVE_AS = "{slug}/index.html"
@ -79,4 +78,8 @@ SITEMAP = {
"format": "xml" "format": "xml"
} }
import filters
JINJA_FILTERS = {
"datetime": filters.format_datetime
}
# Extra context # Extra context

5
plugins/filters.py Normal file
View file

@ -0,0 +1,5 @@
import iso8601
def format_datetime(value):
return iso8601.parse_date(str(value)).strftime("%x")

View file

@ -1,5 +1,6 @@
colorama==0.3.6 colorama==0.3.6
flake8==2.5.0 flake8==2.5.0
gitpython==2.0.3 gitpython==2.0.3
iso8601==0.1.11
markdown==2.6.6 markdown==2.6.6
pelican==3.6.3 pelican==3.6.3

View file

@ -19,7 +19,7 @@
<div class="container"> <div class="container">
<p class="text-right"> <p class="text-right">
Updated: {{ article.updated }} Updated: {{ article.updated }}
Date: {{ article.date }} Date: {{ article.date|datetime }}
</p> </p>
{{ article.content }} {{ article.content }}
</div> </div>