fix spec and simplify code

This commit is contained in:
Joffrey JAFFEUX 2018-05-18 17:13:58 +02:00 committed by GitHub
parent 9a5aa39740
commit d57a17879a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 3 deletions

View File

@ -13,9 +13,12 @@ enabled_site_setting :discourse_local_dates_enabled
after_initialize do
on(:reduce_cooked) do |fragment|
container = fragment.children[0].children[0]
preview = container.attributes["data-email-preview"].value
container.content = preview
container = fragment.css(".discourse-local-date").first
if container
preview = container.attributes["data-email-preview"].value
container.content = preview
end
end
end