changeset 6245:b21822aaacb5

helpers: gravatar_div: allow generating attributes with dashes
author Andrew Shadura <andrew@shadura.me>
date Fri, 23 Sep 2016 17:51:59 +0200
parents 3e46e6b6a27a
children 24a0c176a63d
files kallithea/lib/helpers.py
diffstat 1 files changed, 3 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/kallithea/lib/helpers.py	Fri Sep 23 17:50:48 2016 +0200
+++ b/kallithea/lib/helpers.py	Fri Sep 23 17:51:59 2016 +0200
@@ -820,7 +820,8 @@
 def gravatar_div(email_address, cls='', size=30, **div_attributes):
     """Return an html literal with a div around a gravatar if they are enabled.
     Extra keyword parameters starting with 'div_' will get the prefix removed
-    and be used as attributes on the div. The default class is 'gravatar'.
+    and '_' changed to '-' and be used as attributes on the div. The default
+    class is 'gravatar'.
     """
     from pylons import tmpl_context as c
     if not c.visual.use_gravatar:
@@ -830,7 +831,7 @@
     attributes = []
     for k, v in sorted(div_attributes.items()):
         assert k.startswith('div_'), k
-        attributes.append(' %s="%s"' % (k[4:], escape(v)))
+        attributes.append(' %s="%s"' % (k[4:].replace('_', '-'), escape(v)))
     return literal("""<div%s>%s</div>""" %
                    (''.join(attributes),
                     gravatar(email_address, cls=cls, size=size)))