from django.template import defaultfilters as filters
from avocado.formatters import Formatter, registry


class HTMLFormatter(Formatter):
    def to_html(self, values, fields=None, **context):
        toks = []
        for value in values.values():
            if value is None:
                continue
            if type(value) is float:
                tok = filters.floatformat(value)
            else:
                tok = unicode(value)
            toks.append(tok)
        return u' '.join(toks)

    to_html.process_multiple = True


registry.register(HTMLFormatter, 'HTML')

from django.template import defaultfilters as filters
from avocado.formatters import Formatter


class HTMLFormatter(Formatter):
    delimiter = u' '

    html_map = {
        None: '<em>n/a</em>'
    }

    def to_html(self, values, **context):
        toks = []
        for value in values.values():
            # Check the html_map first
            if value in self.html_map:
                tok = self.html_map[value]
            # Ignore NoneTypes
            elif value is None:
                continue
            # Prettify floats
            elif type(value) is float:
                tok = filters.floatformat(value)
            else:
                tok = unicode(value)
            toks.append(tok)
        return self.delimiter.join(toks)

    to_html.process_multiple = True

Add `delimiter` and `html_map` to HTML formatter and do not register it by default
Add `delimiter` and `html_map` to HTML formatter and do not register it by default
  from django.template import defaultfilters as filters
- from avocado.formatters import Formatter, registry
+ from avocado.formatters import Formatter
  
  
  class HTMLFormatter(Formatter):
+     delimiter = u' '
+ 
+     html_map = {
+         None: '<em>n/a</em>'
+     }
+ 
-     def to_html(self, values, fields=None, **context):
+     def to_html(self, values, **context):
          toks = []
          for value in values.values():
+             # Check the html_map first
+             if value in self.html_map:
+                 tok = self.html_map[value]
+             # Ignore NoneTypes
-             if value is None:
+             elif value is None:
                  continue
+             # Prettify floats
-             if type(value) is float:
+             elif type(value) is float:
                  tok = filters.floatformat(value)
              else:
                  tok = unicode(value)
              toks.append(tok)
-         return u' '.join(toks)
+         return self.delimiter.join(toks)
  
      to_html.process_multiple = True
  
- 
- registry.register(HTMLFormatter, 'HTML')
- 
Add `delimiter` and `html_map` to HTML formatter and do not register it by default
## Code Before:
from django.template import defaultfilters as filters
from avocado.formatters import Formatter, registry


class HTMLFormatter(Formatter):
    def to_html(self, values, fields=None, **context):
        toks = []
        for value in values.values():
            if value is None:
                continue
            if type(value) is float:
                tok = filters.floatformat(value)
            else:
                tok = unicode(value)
            toks.append(tok)
        return u' '.join(toks)

    to_html.process_multiple = True


registry.register(HTMLFormatter, 'HTML')

## Instruction:
Add `delimiter` and `html_map` to HTML formatter and do not register it by default
## Code After:
from django.template import defaultfilters as filters
from avocado.formatters import Formatter


class HTMLFormatter(Formatter):
    delimiter = u' '

    html_map = {
        None: '<em>n/a</em>'
    }

    def to_html(self, values, **context):
        toks = []
        for value in values.values():
            # Check the html_map first
            if value in self.html_map:
                tok = self.html_map[value]
            # Ignore NoneTypes
            elif value is None:
                continue
            # Prettify floats
            elif type(value) is float:
                tok = filters.floatformat(value)
            else:
                tok = unicode(value)
            toks.append(tok)
        return self.delimiter.join(toks)

    to_html.process_multiple = True
