app/helpers/bootstrap/icon_renderer.rb in bootstrap-view-helpers-0.0.13 vs app/helpers/bootstrap/icon_renderer.rb in bootstrap-view-helpers-0.0.14
- old
+ new
@@ -1,8 +1,9 @@
# @private
class Bootstrap::IconRenderer
ArgumentError = Class.new(StandardError)
+ include ActionView::Helpers::SanitizeHelper
delegate :canonicalize_options, :content_tag, :ensure_class, :h, to: :template
attr_accessor :template, :options, :args, :text
def initialize(template, *args)
@@ -31,11 +32,11 @@
process_text
end
def process_icon_type
icon_type = args.shift.presence or raise(ArgumentError, "must pass an icon type")
- icon_class = icon_type == 'blank' ? 'icon-search' : "icon-#{icon_type.gsub("_", "-")}"
+ icon_class = icon_type == 'blank' ? 'glyphicon glyphicon-search' : "glyphicon glyphicon-#{icon_type.gsub("_", "-")}"
self.options = ensure_class(self.options, icon_class)
if icon_type == 'blank'
options[:style] = [options[:style], 'opacity: 0'].map(&:presence).compact.join('; ')
end
@@ -49,10 +50,10 @@
def process_text
self.text = if args.size == 0
nil
elsif args.size == 1
- h(" #{args.first}")
+ sanitize(" #{args.first}")
else
raise ArgumentError, 'too many arguments'
end
end
\ No newline at end of file