Files
nairobi/app/helpers/text_with_links_helper.rb
Javi Martín d0d681a44b Add and apply EmptyLineAfterGuardClause rule
We were inconsistent on this one. I consider it particularly useful when
a method starts with a `return` statement.

In other cases, we probably shouldn't have a guard rule in the middle of
a method in any case, but that's a different refactoring.
2019-10-24 17:56:03 +02:00

20 lines
533 B
Ruby

module TextWithLinksHelper
def sanitize_and_auto_link(text)
return unless text
sanitized = sanitize(text, tags: [], attributes: [])
auto_link_already_sanitized_html(sanitized)
end
def auto_link_already_sanitized_html(html)
return if html.nil?
raise "Could not add links because the content is not safe" unless html.html_safe?
raw Rinku.auto_link(html, :all, 'target="_blank" rel="nofollow"')
end
def simple_format_no_tags_no_sanitize(html)
simple_format(html, {}, sanitize: false)
end
end