O.M.G. Apparently . . . I can!!! It never would have occurred to me that I could put it there and not all the way up in the template where (in my head, at least) it’s rendered.
I now see and understand that digest_custom and that it’s calling .html_safe, pretty as you please, in code that I looked at and tried to understadnd, but it’s confusing (to me) that it’s using that funky no-parens syntax. (Or maybe I never would have seen it).
Well, I do see the values in the locales, but compared to overwriting the template like I was doing before, this is a much less risky solution.
Thanks so very much for putting me on the right path!
Here’s one other thing I’m doing that feels silly. My digest_custom_html needs the user that it’s rendered for, so what I’m doing is overriding digest to set @user so that my digets_custom_html can have access to the user that the digest is for. Is there some super-easy way that I can avoid doing that?
after_initialize do
# Code which should run after Rails has finished booting
# require_relative "lib/discourse_add_jobs_to_digest/user_notifications_helper_override"
require_relative "lib/discourse_add_jobs_to_digest/engine"
require_relative "lib/discourse_add_jobs_to_digest/job_api"
require_dependency "user_notifications"
module ::UserNotificationsHelperOverride
def digest_custom_html(position_key)
if position_key == "above_footer"
DiscourseAddJobsToDigest::JobApi.get_jobs_html(@user).html_safe
else
super
end
end
end
UserNotificationsHelper.prepend(::UserNotificationsHelperOverride)
module ::UserNotificationsOverride
def digest(user, opts = {})
@user = user
super
end
end
UserNotifications.prepend(::UserNotificationsOverride)
end