Fixing digest_custom_html to be treated as HTML (was: Overriding digest.html.erb)

Could you add the .html_safe to the result of your method override? I don’t think there’s any reason it needs to be in the erb template?

The general aim, both in Rails and in Ember, is to put the “this string is html safe” as close to the authoring/generating point, so that it’s super clear to developers that they need to make sure the HTML is indeed safe (i.e. any user input is escaped)

What you’re doing is ok (as long as it’s tested), but it’s not the “intended” use for these methods. If it was an intentional plugin api, it would be in plugin/instance.rb with the others.

The intended use for this method is to put markdown into the matching translation key:

(Also note the html_safe there - that’s the same technique you’d need to use in any override)

2 Likes