Skip to content
This repository has been archived by the owner on Mar 15, 2018. It is now read-only.

Commit

Permalink
helper-ify time labels
Browse files Browse the repository at this point in the history
  • Loading branch information
potch committed May 16, 2012
1 parent 253385e commit bd070b1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
5 changes: 1 addition & 4 deletions mkt/detail/templates/detail/app.html
Expand Up @@ -225,10 +225,7 @@ <h3>{{ _('More Info') }}</h3>
<li class="published">
<h3>{{ _('Published') }}</h3>
<p>
<time isotime="{{ product.created|isotime }}"
title="{{ product.created|isotime }}">
{{ product.created|timesince }}
</time>
{{ product.created|timelabel }}
</p>
</li>
</ul>
Expand Down
7 changes: 7 additions & 0 deletions mkt/site/helpers.py
Expand Up @@ -166,6 +166,13 @@ def grid_field(field, label=None, tag='div', req=None, opt=False, hint=False,
cc_startswith, cc_maxlength, grid=True, attrs=attrs)


@register.filter
@jinja2.contextfilter
def timelabel(context, time):
t = env.get_template('site/helpers/timelabel.html').render(time=time)
return jinja2.Markup(t)


@register.function
def admin_site_links():
return {
Expand Down
4 changes: 4 additions & 0 deletions mkt/site/templates/site/helpers/timelabel.html
@@ -0,0 +1,4 @@
<time isotime="{{ time|isotime }}"
title="{{ time|isotime }}">
{{ time|timesince }}
</time>

0 comments on commit bd070b1

Please sign in to comment.