Module: Precious::Views::OcticonHelpers

Included in:
Layout
Defined in:
lib/gollum/views/helpers.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/gollum/views/helpers.rb', line 72

def self.included(base)
  
  def rocticon(symbol, parameters = {})
    Octicons::Octicon.new(symbol, parameters).to_svg
  end

  # Well-formed SVG with XMLNS and height/width removed, for use in CSS
  def rocticon_css(symbol, parameters = {})
    octicon = ::Octicons::Octicon.new(symbol, parameters.merge({xmlns: 'http://www.w3.org/2000/svg'}))
    [:width, :height].each {|option| octicon.options.delete(option)}
    octicon.to_svg
  end
  
  def octicon
    lambda do |args|
      symbol, height, width = args.split(' ')
      parameters = {}
      parameters[:height] = height if height
      parameters[:width]  = width if width
      Octicons::Octicon.new(symbol, parameters).to_svg
    end
  end
end

Instance Method Details

#octiconObject



85
86
87
88
89
90
91
92
93
# File 'lib/gollum/views/helpers.rb', line 85

def octicon
  lambda do |args|
    symbol, height, width = args.split(' ')
    parameters = {}
    parameters[:height] = height if height
    parameters[:width]  = width if width
    Octicons::Octicon.new(symbol, parameters).to_svg
  end
end

#rocticon(symbol, parameters = {}) ⇒ Object



74
75
76
# File 'lib/gollum/views/helpers.rb', line 74

def rocticon(symbol, parameters = {})
  Octicons::Octicon.new(symbol, parameters).to_svg
end

#rocticon_css(symbol, parameters = {}) ⇒ Object

Well-formed SVG with XMLNS and height/width removed, for use in CSS



79
80
81
82
83
# File 'lib/gollum/views/helpers.rb', line 79

def rocticon_css(symbol, parameters = {})
  octicon = ::Octicons::Octicon.new(symbol, parameters.merge({xmlns: 'http://www.w3.org/2000/svg'}))
  [:width, :height].each {|option| octicon.options.delete(option)}
  octicon.to_svg
end