Comment by klausi here https://www.drupal.org/node/2386275#comment-9618711:
shariff_field_formatter_view(): don't use #markup and theme() here, just return a render array in $element (Drupal core will render later for you and it is best to keep structured arrays as long as possible for alttering by other modules).
Comments
Comment #1
crizComment #3
crizI am not sure about this, the field example module is using
'#type' => 'html_tag': https://api.drupal.org/api/examples/field_example%21field_example.module...But theme_html_tag doesn't really makes any sense to me in this case (only for rendering html meta tags) and I prefer to use our own theme function for consistency. So I used #theme => 'shariff' and changed $settings to be used as render_variables.
http://cgit.drupalcode.org/sandbox-criz-2385117/commit/?id=228910a