Make Taggable.format_tags more readable.
This commit is contained in:
parent
24702b9f6a
commit
73c79bdc0d
1 changed files with 6 additions and 5 deletions
|
|
@ -41,12 +41,13 @@ module Diaspora
|
|||
|
||||
def self.format_tags(text, opts={})
|
||||
return text if opts[:plain_text]
|
||||
|
||||
text = ERB::Util.h(text) unless opts[:no_escape]
|
||||
regex = /(^|\s|>)#(#{VALID_TAG_BODY})/
|
||||
form_message = text.to_str.gsub(regex) do |matched_string|
|
||||
"#{$~[1]}<a href=\"/tags/#{$~[2]}\" class=\"tag\">##{$~[2]}</a>"
|
||||
end
|
||||
form_message.html_safe
|
||||
|
||||
text.to_str.gsub(regex) { |matched_string|
|
||||
%{#{$1}<a href="/tags/#{$2}" class="tag">##{$2}</a>}
|
||||
}.html_safe
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in a new issue