Generalize link arguments in text_with_links util.

This commit is contained in:
Max Goodman
2011-11-10 12:14:45 -08:00
parent 8d802164a7
commit cfa0582858
2 changed files with 8 additions and 6 deletions

View File

@@ -46,10 +46,10 @@
${text_with_links(
_("Use of this site constitutes acceptance of our "
"%(user_agreement)s and %(privacy_policy)s"), nocname=True,
user_agreement= (_("User Agreement {Genitive}"),
"http://reddit.com/help/useragreement"),
privacy_policy = (_("Privacy Policy {Genitive}"),
"http://reddit.com/help/privacypolicy"))}.
user_agreement = dict(link_text=_("User Agreement {Genitive}"),
path="http://reddit.com/help/useragreement"),
privacy_policy = dict(link_text=_("Privacy Policy {Genitive}"),
path="http://reddit.com/help/privacypolicy"))}.
© ${_("%(year)d reddit inc. All rights reserved.") % \
dict(year=datetime.datetime.now().timetuple()[0])}
</p>

View File

@@ -171,8 +171,10 @@ ${first_defined(kw[1:])}
<%def name="text_with_links(txt, _sr_path = False, nocname=False, **kw)">
<%
from r2.lib.filters import _force_unicode
for key, (text, href) in kw.iteritems():
kw[key]=spaceCompress(capture(plain_link, text, href, _sr_path=_sr_path, nocname=nocname))
for key, link_args in kw.iteritems():
link_args.setdefault("_sr_path", _sr_path)
link_args.setdefault("nocname", nocname)
kw[key]=spaceCompress(capture(plain_link, **link_args))
txt = _force_unicode(txt) % kw
txt = txt.replace(" <", "&#32;<").replace("> ", ">&#32;")