diff --git a/apps/reviews/helpers.py b/apps/reviews/helpers.py
index 3c9a047543..6ecce3c365 100644
--- a/apps/reviews/helpers.py
+++ b/apps/reviews/helpers.py
@@ -15,13 +15,9 @@ def stars(num, large=False):
return _('Not yet rated')
else:
num = min(5, int(round(num)))
- rating = '%s' % num
- title = _('Rated %s out of 5 stars') % num
- msg = _('Rated %s out of 5 stars') % rating
- size = 'large ' if large else ''
- s = (u'{msg}'
- .format(num=num, size=size, title=title, msg=msg))
- return jinja2.Markup(s) # Inspected by #10
+ t = jingo.env.get_template('reviews/impala/reviews_rating.html')
+ # These are getting renamed for contextual sense in the template.
+ return jinja2.Markup(t.render(rating=num, detailpage=large))
@jingo.register.function
diff --git a/apps/reviews/templates/reviews/impala/reviews_rating.html b/apps/reviews/templates/reviews/impala/reviews_rating.html
new file mode 100644
index 0000000000..e8fd20b111
--- /dev/null
+++ b/apps/reviews/templates/reviews/impala/reviews_rating.html
@@ -0,0 +1,12 @@
+{% set title = _('Rated {0} out of 5 stars')|f(rating) %}
+{% if detailpage %}
+
+
+ {% trans %}
+ Rated {{ rating }} out of
+ 5 stars
+ {% endtrans %}
+
+{% else %}
+ {{ title }}
+{% endif %}
diff --git a/apps/reviews/tests/test_helpers.py b/apps/reviews/tests/test_helpers.py
index 5024ab0759..2e34290b81 100644
--- a/apps/reviews/tests/test_helpers.py
+++ b/apps/reviews/tests/test_helpers.py
@@ -29,6 +29,14 @@ def test_stars():
eq_(doc.text(), msg)
+def test_stars_details_page():
+ doc = pq(render('{{ num|stars(large=True) }}', {'num': 2}))
+ eq_(doc('.stars').attr('class'), 'stars large stars-2')
+ eq_(doc('meta[itemprop="worstRating"]').attr('content'), '1')
+ eq_(doc('span[itemprop="ratingValue"]').text(), '2')
+ eq_(doc('span[itemprop="bestRating"]').text(), '5')
+
+
def test_stars_max():
doc = pq(render('{{ num|stars }}', {'num': 5.3}))
eq_(doc.attr('class'), 'stars stars-5')