2018-05-24 18:01:40 +02:00
|
|
|
module StringToHtmlHelper
|
2019-11-06 16:30:20 +01:00
|
|
|
def string_to_html(str, wrapper_tag = 'p')
|
2022-02-02 18:03:24 +01:00
|
|
|
return nil if str.blank?
|
2019-11-06 16:30:20 +01:00
|
|
|
html_formatted = simple_format(str, {}, { wrapper_tag: wrapper_tag })
|
2020-06-22 14:42:10 +02:00
|
|
|
with_links = Anchored::Linker.auto_link(html_formatted, target: '_blank', rel: 'noopener')
|
2019-03-05 18:16:13 +01:00
|
|
|
sanitize(with_links, attributes: ['target', 'rel', 'href'])
|
2018-05-24 18:01:40 +02:00
|
|
|
end
|
|
|
|
end
|