Module: GlyphExtension

Included in:
UiBibz::Ui::Core::Component
Defined in:
lib/ui_bibz/ui/extensions/core/component/glyph_extension.rb

Instance Method Summary collapse

Instance Method Details

#generate_glyph(content_html) ⇒ Object

Render glyph html



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/ui_bibz/ui/extensions/core/component/glyph_extension.rb', line 10

def generate_glyph(content_html)
  glyph_options = if options[:glyph].is_a?(Hash)
                    options[:glyph]
                  elsif options[:glyph]
                    { name: options[:glyph] }
                  else
                    {}
                  end

  glyph_options = glyph_options.tap do |h|
    h[:text] = options[:text]
    h[:label] = options[:label] || content_html || content
    h[:shortcut] = options[:shortcut] unless options[:shortcut].nil?
  end

  # UiBibz::Utils::GlyphChanger.new(glyph_options[:name], glyph_options).render unless glyph_options[:name].nil?
  UiBibz::Ui::Core::Icons::Glyph.new(glyph_options[:name], glyph_options).render if glyph_options[:name].present?
end

#glyph_and_content_html(content_html = nil) ⇒ Object

Render glyph and content html



5
6
7
# File 'lib/ui_bibz/ui/extensions/core/component/glyph_extension.rb', line 5

def glyph_and_content_html(content_html = nil)
  options[:glyph] ? generate_glyph(content_html) : content_html || content
end