metadata.date is not available but metadata.formatted_date is available while rendering page.html

15 views
Skip to first unread message

basi...@gmail.com

unread,
Apr 2, 2013, 9:04:54 AM4/2/13
to tinker...@googlegroups.com
A very strange issue: trying to output the date in page.html as follows:

{%- block body -%}
    {{ timestamp(metadata.date.strftime('%A, %d %B %Y').upper()) }}
    ...


The error:

    return not (getattr(obj, 'unsafe_callable', False) or
    UndefinedError: 'None' has no attribute 'strftime'

But metadata.formatted_date works fine! 

And metadata.date works perfectly in aggregated.html

Anyone has an idea what is happening with metadata.date?

Vlad Riscutia

unread,
Apr 2, 2013, 12:37:17 PM4/2/13
to tinker...@googlegroups.com
page.html is also used for non-posts (blog pages) and pages don't have date. You probably want to make sure there actually is a date before formatting it: ( {%- if metadata.date %}

Thank you,
Vlad


--
You received this message because you are subscribed to the Google Groups "tinkerer-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tinkerer-dev...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

basi...@gmail.com

unread,
Apr 3, 2013, 8:09:39 AM4/3/13
to tinker...@googlegroups.com
Hi Vlad,

But in this case, why metadata.formatted_date is available? Isn't it a bit inconsistent to have actually the formatted_date, and not have the normal date?

Thank you, 
Zaur

Vlad Riscutia

unread,
Apr 3, 2013, 11:36:54 AM4/3/13
to tinker...@googlegroups.com
Yeah, it is a bit weird, though I'm not sure how this happens. Can you provide some repro steps? What pages/posts are you seeing this with?

Thank you,
Vlad
Reply all
Reply to author
Forward
0 new messages