def page_title(context, title): title = smart_text(title) base_title = page_name(context['request'].APP) # The following line doesn't use string formatting because we want to # preserve the type of `title` in case it's a jinja2 `Markup` (safe, # escaped) object. return django_format_html(u'{} :: {}', title, base_title)
def page_title(context, title): title = smart_text(title) base_title = ugettext('Add-ons for {0}').format(amo.FIREFOX.pretty) # The following line doesn't use string formatting because we want to # preserve the type of `title` in case it's a jinja2 `Markup` (safe, # escaped) object. return django_format_html('{} :: {}', title, base_title)
def format_html(string, *args, **kwargs): """Uses ``str.format`` for string interpolation. Uses ``django.utils.html:format_html`` internally. >>> {{ "{0} arguments, {x} arguments"|format_html('args', x='kwargs') }} "positional args, kwargs arguments" Checks both, *args and **kwargs for potentially unsafe arguments ( not marked as `mark_safe`) and escapes them appropriately. """ return django_format_html(smart_text(string), *args, **kwargs)