修复当课程描述中有特殊标签是,课程列表描述显示有误的BUG
This commit is contained in:
parent
39434766e3
commit
47ad20421e
|
@ -92,10 +92,21 @@ class Course < ActiveRecord::Base
|
|||
|
||||
# 课程的短描述信息
|
||||
def short_description(length = 255)
|
||||
description.gsub(/<\/?.*?>/,"").strip if description
|
||||
description.gsub(/<\/?.*?>/,"").html_safe if description
|
||||
#description.gsub(/^(.{#{length}}[^\n\r]*).*$/m, '\1...').strip if description
|
||||
end
|
||||
|
||||
def strip_html(html)
|
||||
return html if html.empty? || !html.include?('<')
|
||||
output = ""
|
||||
tokenizer = HTML::Tokenizer.new(html)
|
||||
while token = tokenizer.next
|
||||
node = HTML::Node.parse(nil, 0, 0, token, false)
|
||||
output += token unless (node.kind_of? HTML::Tag) or (token =~ /^<!/)
|
||||
end
|
||||
return output
|
||||
end
|
||||
|
||||
def extra_frozen?
|
||||
errors[:extra].blank? && !(new_record? || extra.blank?)
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue