[Fix #1801] rename and move html_formatted_description in a generic helper
This commit is contained in:
parent
0635b50d70
commit
152cf03d72
3 changed files with 10 additions and 9 deletions
|
@ -2,10 +2,4 @@ module ChampHelper
|
||||||
def is_not_header_nor_explication?(champ)
|
def is_not_header_nor_explication?(champ)
|
||||||
!['header_section', 'explication'].include?(champ.type_champ)
|
!['header_section', 'explication'].include?(champ.type_champ)
|
||||||
end
|
end
|
||||||
|
|
||||||
def html_formatted_description(description)
|
|
||||||
html_formatted = simple_format(description)
|
|
||||||
with_links = html_formatted.gsub(URI.regexp, '<a target="_blank" href="\0">\0</a>')
|
|
||||||
sanitize(with_links, attributes: %w(href target))
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
7
app/helpers/string_to_html_helper.rb
Normal file
7
app/helpers/string_to_html_helper.rb
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
module StringToHtmlHelper
|
||||||
|
def string_to_html(str)
|
||||||
|
html_formatted = simple_format(str)
|
||||||
|
with_links = html_formatted.gsub(URI.regexp, '<a target="_blank" href="\0">\0</a>')
|
||||||
|
sanitize(with_links, attributes: %w(href target))
|
||||||
|
end
|
||||||
|
end
|
|
@ -1,6 +1,6 @@
|
||||||
RSpec.describe ChampHelper, type: :helper do
|
RSpec.describe StringToHtmlHelper, type: :helper do
|
||||||
describe "#html_formatted_description" do
|
describe "#string_to_html" do
|
||||||
subject { html_formatted_description(description) }
|
subject { string_to_html(description) }
|
||||||
|
|
||||||
context "with some simple texte" do
|
context "with some simple texte" do
|
||||||
let(:description) { "1er ligne \n 2ieme ligne" }
|
let(:description) { "1er ligne \n 2ieme ligne" }
|
Loading…
Add table
Reference in a new issue