We were very inconsistent regarding these rules. Personally I prefer no empty lines around blocks, clases, etc... as recommended by the Ruby style guide [1], and they're the default values in rubocop, so those are the settings I'm applying. The exception is the `private` access modifier, since we were leaving empty lines around it most of the time. That's the default rubocop rule as well. Personally I don't have a strong preference about this one. [1] https://rubystyle.guide/#empty-lines-around-bodies
19 lines
532 B
Ruby
19 lines
532 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
|