Closed
Bug 1225161
Opened 9 years ago
Closed 9 years ago
ditch fe jinja2 filter and use Jinja2 newstyle gettext instead
Categories
(developer.mozilla.org Graveyard :: Code Cleanup, defect)
developer.mozilla.org Graveyard
Code Cleanup
Tracking
(Not tracked)
RESOLVED
FIXED
People
(Reporter: robhudson, Assigned: robhudson)
References
Details
+++ This bug was initially created as a clone of Bug #1222040 +++ Fjord has an fe (format escaped) filter that we inherited from Tower that allows us to do the following in templates: {{ _('Response: {id}')|fe(id=response.id) }} In this expression, gettext is called with the msgid "Response: {id}" and it returns a translated form of that string. The resulting string is marked as Jinja2-safe by Fjord's adjusted gettext, so nothing is escaped in this string. Then the string is passed to the fe filter which evaluates response.id in the context, escapes that value and then interpolates it into the string using Python's .format(). Yay! This is what we want! However, there are two problems. 1. fe requires that we use python-brace-format (e.g. {}) variables which we want to get rid of (bug #1220657) 2. Jinja2's newstyle gettext already does this: {{ _('Response: %(id)s', id=response.id) }} Here's a more complex example. With fe: <h2>{{ _('<b>Response id: {id}</b>')|fe(id='<i>102</i>') }}</h2> This comes out as: <b>Response id: <i>102</i></b> where the <b> </b> is not escaped and the <i> </i> are. The equivalent with newstyle gettext: <h2>{{ _('<b>Response id: %(id)s</b>', id='<i>102</i>') }}</h2> produces the same thing. This bug covers getting rid of our fe filter in favor of Jinja2's newstyle gettext.
Assignee | ||
Updated•9 years ago
|
Comment 1•9 years ago
|
||
Commits pushed to master at https://github.com/mozilla/kuma https://github.com/mozilla/kuma/commit/a9c7acd289f8d8d0b0e6702e473b1fae94ba852a Fix bug 1225161 - Use newstyle gettext in favor of |f and |fe https://github.com/mozilla/kuma/commit/4838c29847fa6f58935ceefb2a23a641df4e0ad2 Merge pull request #3654 from robhudson/1225161-no-jingo-filters Fix bug 1225161 - Use newstyle gettext in favor of |f and |fe
Updated•9 years ago
|
Status: NEW → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Comment 2•9 years ago
|
||
Commit pushed to master at https://github.com/mozilla/kuma https://github.com/mozilla/kuma/commit/d571998b78c444ed73d93bf294f66bc768bd2066 Bug 1225161 - Missed a few uses of "|f"
Updated•4 years ago
|
Product: developer.mozilla.org → developer.mozilla.org Graveyard
You need to log in
before you can comment on or make changes to this bug.
Description
•