Sha256: 5dc3a34a7894502c48d64578abf522a7f68b5cc5511ed543fe5474eaf8f2c751

Contents?: true

Size: 1.07 KB

Versions: 2

Compression:

Stored size: 1.07 KB

Contents

module GlyphExtension

  # Render glyph and content html
  def glyph_and_content_html content_html = nil
    [glyph_with_space, ct_html(content_html)].compact.join(' ').html_safe
  end

  def ct_html content_html
    if options[:text].nil? || options[:text] == true
      content_html || content
    end
  end

  # Render glyph with space html
  def glyph_with_space
    out = [glyph]
    out << " " if options[:text] != false
    out.join unless glyph.nil?
  end

  # Render glyph html
  def glyph
    options[:content] = content if options[:text] == false

    glyph_options = if options[:glyph].kind_of?(Hash)
      options[:glyph]
    elsif options[:glyph].kind_of?(String)
      { name: options[:glyph] }
    else
      {}
    end

    glyph_options[:text]     = options[:text] unless options[:text].nil?
    glyph_options[:content]  = options[:content] unless options[:content].nil?
    glyph_options[:shortcut] = options[:shortcut] unless options[:shortcut].nil?

    UiBibz::Utils::GlyphChanger.new(glyph_options[:name], glyph_options).render unless glyph_options[:name].nil?
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ui_bibz-2.1.5 lib/ui_bibz/ui/extensions/core/component/glyph_extension.rb
ui_bibz-2.1.4 lib/ui_bibz/ui/extensions/core/component/glyph_extension.rb