From c609a4b3a12a22b32d7d8f7913b507fff3d3decf Mon Sep 17 00:00:00 2001 From: Arnaud Levy <contact@arnaudlevy.com> Date: Fri, 3 Feb 2023 14:32:21 +0100 Subject: [PATCH] Fix #788 --- app/models/concerns/with_inheritance.rb | 6 ++++-- app/services/static.rb | 6 ++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/app/models/concerns/with_inheritance.rb b/app/models/concerns/with_inheritance.rb index 7f7dd625c..e080daef0 100644 --- a/app/models/concerns/with_inheritance.rb +++ b/app/models/concerns/with_inheritance.rb @@ -23,12 +23,14 @@ module WithInheritance def best(property) value = send(property) - value.blank? ? parent&.send("best_#{property}") : value + text = Static.html_to_text value.to_html + text.blank? ? parent&.send("best_#{property}") : value end def best_source(property, is_ancestor: false) value = send(property) - return (is_ancestor ? self : nil) if value.present? + text = Static.html_to_text value.to_html + return (is_ancestor ? self : nil) if text.present? parent&.send(:best_source, property, is_ancestor: true) end end diff --git a/app/services/static.rb b/app/services/static.rb index f74f72c2f..9e0ad12cf 100644 --- a/app/services/static.rb +++ b/app/services/static.rb @@ -9,6 +9,12 @@ class Static string end + def self.html_to_text(string) + string = ActionController::Base.helpers.strip_tags string + string = string.strip + string + end + def self.render(template_static, about, website) code = ApplicationController.render( template: template_static, -- GitLab