fix: improve tag formatting functionality
- Update `format_as_tag` method to replace hyphens with underscores in addition to spaces. - Ensure the method handles blank inputs properly. This change improves the consistency of tag formatting by ensuring that both spaces and hyphens are converted into underscores, enhancing the usability and reliability of this helper method.
This commit is contained in:
parent
f4337240f7
commit
2aad3ec5b4
@ -2,9 +2,8 @@ module TagHelper
|
||||
def format_as_tag(text)
|
||||
return nil if text.blank?
|
||||
|
||||
# 空格改为下划线
|
||||
text.strip.gsub(/\s+/, "_")
|
||||
text.strip.gsub("-", "_")
|
||||
# 空格改为下划线, 中划线改为下划线
|
||||
text.strip.gsub(/\s+/, "_").gsub("-", "_")
|
||||
|
||||
# 或者删除空格 (选项2)
|
||||
# text.strip.gsub(/\s+/, '')
|
||||
|
Loading…
Reference in New Issue
Block a user