Class: Jekyll::Colors

Inherits:
Liquid::Block
  • Object
show all
Defined in:
lib/jekyll-gl.rb

Instance Method Summary collapse

Constructor Details

#initialize(tag_name, markup, options) ⇒ Colors

Returns a new instance of Colors.



117
118
119
120
121
# File 'lib/jekyll-gl.rb', line 117

def initialize(tag_name, markup, options)
  super

  @font_family = markup
end

Instance Method Details

#render(context) ⇒ Object



123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
# File 'lib/jekyll-gl.rb', line 123

def render(context)
  content = ''

  super.split(/[\n]/).each do |val|
    next if val == ''

    data = (val && val.split(';')) || [];
    content += '<li title="{{var}}" style="background-color:{{color}};"></li>'
      .sub('{{var}}', data[1] || data[0] || '')
      .gsub('{{color}}', data[0] || '');
  end

  '<ul class="gl-colors">{{content}}</ul>'
    .sub('{{content}}', content)
end