module CategoryBadge def self.html_for(category, opts=nil) opts = opts || {} # If there is no category, bail return "" if category.blank? # By default hide uncategorized return "" if category.uncategorized? && !opts[:show_uncategorized] category_url = "#{Discourse.base_url}#{category.url}" result = "" result << " " unless category.parent_category_id.nil? parent_category = Category.find_by(id: category.parent_category_id) result << " " end result << "#{category.name}" "#{result}" end end