
from . import dateformat, money


def dim(value):
    """Render value in a way so that it looks dimmed."""
    return '<span class="dimmed">{}</span>'.format(value)


def register(app):
    """Make functions available as template filters."""
    functions = [
        dateformat.format_custom,
        dateformat.format_date_iso,
        dateformat.format_date_short,
        dateformat.format_date_long,
        dateformat.format_datetime_iso,
        dateformat.format_datetime_short,
        dateformat.format_datetime_long,
        dateformat.format_time,
        dim,
        money.format_euro_amount,
    ]

    for f in functions:
        app.add_template_filter(f)


from jinja2 import evalcontextfilter, Markup

from . import dateformat, money


@evalcontextfilter
def dim(eval_ctx, value):
    """Render value in a way so that it looks dimmed."""
    dimmed = '<span class="dimmed">{}</span>'.format(value)
    return Markup(dimmed) if eval_ctx.autoescape else dimmed


def register(app):
    """Make functions available as template filters."""
    functions = [
        dateformat.format_custom,
        dateformat.format_date_iso,
        dateformat.format_date_short,
        dateformat.format_date_long,
        dateformat.format_datetime_iso,
        dateformat.format_datetime_short,
        dateformat.format_datetime_long,
        dateformat.format_time,
        dim,
        money.format_euro_amount,
    ]

    for f in functions:
        app.add_template_filter(f)

Mark HTML generated by custom template filter as safe if auto-escaping is enabled.
Mark HTML generated by custom template filter as safe if auto-escaping is enabled.

+ 
+ from jinja2 import evalcontextfilter, Markup
  
  from . import dateformat, money
  
  
+ @evalcontextfilter
- def dim(value):
+ def dim(eval_ctx, value):
      """Render value in a way so that it looks dimmed."""
-     return '<span class="dimmed">{}</span>'.format(value)
+     dimmed = '<span class="dimmed">{}</span>'.format(value)
+     return Markup(dimmed) if eval_ctx.autoescape else dimmed
  
  
  def register(app):
      """Make functions available as template filters."""
      functions = [
          dateformat.format_custom,
          dateformat.format_date_iso,
          dateformat.format_date_short,
          dateformat.format_date_long,
          dateformat.format_datetime_iso,
          dateformat.format_datetime_short,
          dateformat.format_datetime_long,
          dateformat.format_time,
          dim,
          money.format_euro_amount,
      ]
  
      for f in functions:
          app.add_template_filter(f)
  
Mark HTML generated by custom template filter as safe if auto-escaping is enabled.
## Code Before:

from . import dateformat, money


def dim(value):
    """Render value in a way so that it looks dimmed."""
    return '<span class="dimmed">{}</span>'.format(value)


def register(app):
    """Make functions available as template filters."""
    functions = [
        dateformat.format_custom,
        dateformat.format_date_iso,
        dateformat.format_date_short,
        dateformat.format_date_long,
        dateformat.format_datetime_iso,
        dateformat.format_datetime_short,
        dateformat.format_datetime_long,
        dateformat.format_time,
        dim,
        money.format_euro_amount,
    ]

    for f in functions:
        app.add_template_filter(f)

## Instruction:
Mark HTML generated by custom template filter as safe if auto-escaping is enabled.
## Code After:

from jinja2 import evalcontextfilter, Markup

from . import dateformat, money


@evalcontextfilter
def dim(eval_ctx, value):
    """Render value in a way so that it looks dimmed."""
    dimmed = '<span class="dimmed">{}</span>'.format(value)
    return Markup(dimmed) if eval_ctx.autoescape else dimmed


def register(app):
    """Make functions available as template filters."""
    functions = [
        dateformat.format_custom,
        dateformat.format_date_iso,
        dateformat.format_date_short,
        dateformat.format_date_long,
        dateformat.format_datetime_iso,
        dateformat.format_datetime_short,
        dateformat.format_datetime_long,
        dateformat.format_time,
        dim,
        money.format_euro_amount,
    ]

    for f in functions:
        app.add_template_filter(f)
