Edgewall Software

Changes between Version 13 and Version 14 of TracDev/PortingFromGenshiToJinja


Ignore:
Timestamp:
Feb 25, 2016, 11:18:07 PM (8 years ago)
Author:
Christian Boos
Comment:

#i18n add an example for tag_

Legend:

Unmodified
Added
Removed
Modified
  • TracDev/PortingFromGenshiToJinja

    v13 v14  
    310310   }}}
    311311   (the need for the `|safe` filter in the above might go away once the following issue //[https://github.com/mitsuhiko/jinja2/issues/490 Should set blocks be safe by default]// gets fixed)
     312
     313Note that another tricky case is when you want to use `gettext` and one of the variables is Markup. Using `|safe` is also needed, but that's not enough, as currently `gettext()` doesn't support Markup, you need to use `tgettext()` which is available with the `tag_` shortcut:
     314{{{#!html+jinja
     315  <em>
     316    # set preferences_link
     317    <a href="${href.prefs()}" class="trac-target-new">${
     318      _("Preferences")}</a>
     319    # endset
     320    ${tag_("Set your email in %(preferences_link)s",
     321           preferences_link=preferences_link|safe)}
     322  </em>
     323}}}
     324
    312325
    313326