comparison piecrust/templating/jinjaengine.py @ 356:019d274e6713

data: Also expose XML date formatting as `xmldate` in Jinja.
author Ludovic Chabant <ludovic@chabant.com>
date Mon, 20 Apr 2015 22:34:49 -0700
parents 498a917cd2d4
children 9e25852f058b
comparison
equal deleted inserted replaced
355:28b021be74eb 356:019d274e6713
147 'nocache': add_no_cache_parameter, 147 'nocache': add_no_cache_parameter,
148 'wordcount': get_word_count, 148 'wordcount': get_word_count,
149 'stripoutertag': strip_outer_tag, 149 'stripoutertag': strip_outer_tag,
150 'stripslash': strip_slash, 150 'stripslash': strip_slash,
151 'titlecase': title_case, 151 'titlecase': title_case,
152 'atomdate': get_atom_date, 152 'atomdate': get_xml_date,
153 'xmldate': get_xml_date,
153 'emaildate': get_email_date, 154 'emaildate': get_email_date,
154 'date': get_date}) 155 'date': get_date})
155 156
156 # Backwards compatibility with Twig. 157 # Backwards compatibility with Twig.
157 if twig_compatibility_mode is True: 158 if twig_compatibility_mode is True:
235 236
236 def title_case(value): 237 def title_case(value):
237 return value.title() 238 return value.title()
238 239
239 240
240 def get_atom_date(value): 241 def get_xml_date(value):
241 return strict_rfc3339.timestamp_to_rfc3339_localoffset(int(value)) 242 return strict_rfc3339.timestamp_to_rfc3339_localoffset(int(value))
242 243
243 244
244 def get_email_date(value, localtime=False): 245 def get_email_date(value, localtime=False):
245 return email.utils.formatdate(value, localtime=localtime) 246 return email.utils.formatdate(value, localtime=localtime)