Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: sitescripts/cms/converters.py

Issue 5352791199449088: Added support for adding addional HTML attributes to the "linkify" template filter (Closed)
Patch Set: Created Feb. 4, 2014, 1:55 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sitescripts/cms/converters.py
===================================================================
--- a/sitescripts/cms/converters.py
+++ b/sitescripts/cms/converters.py
@@ -239,14 +239,16 @@
localedata = self._params["source"].read_locale(self._params["locale"], page)
return jinja2.Markup(self.localize_string(name, localedata, html_escapes, links=links))
- def linkify(self, page, locale=None):
+ def linkify(self, page, locale=None, **attrs):
if locale == None:
locale = self._params["locale"]
locale, url = self._params["source"].resolve_link(page, locale)
- return jinja2.Markup('<a href="%s" hreflang="%s">' % (
- jinja2.Markup.escape(url),
- jinja2.Markup.escape(locale)
+ return jinja2.Markup('<a%s>' % ''.join(
+ ' %s="%s"' % (name, jinja2.escape(value)) for name, value in [
+ ('href', url),
+ ('hreflang', locale)
+ ] + attrs.items()
))
def toclist(self, content):
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld