Class: Jekyll::JekyllGithubChart::JekyllGithubChartTag
- Inherits:
-
Liquid::Tag
- Object
- Liquid::Tag
- Jekyll::JekyllGithubChart::JekyllGithubChartTag
- Defined in:
- lib/jekyll-github-chart.rb
Instance Method Summary collapse
-
#initialize(tag_name, text, tokens) ⇒ JekyllGithubChartTag
constructor
A new instance of JekyllGithubChartTag.
- #render(context) ⇒ Object
Constructor Details
#initialize(tag_name, text, tokens) ⇒ JekyllGithubChartTag
Returns a new instance of JekyllGithubChartTag.
8 9 10 11 12 13 14 |
# File 'lib/jekyll-github-chart.rb', line 8 def initialize(tag_name, text, tokens) super opts = text.split(' ').map(&:strip) @user = opts[0] @scheme = opts[1] || 'default' # old, halloween @format = opts[2] || 'image' # raw end |
Instance Method Details
#render(context) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/jekyll-github-chart.rb', line 16 def render(context) raw_svg = GithubChart.new({ user: @user, colors: @scheme.to_sym }).render(:svg) return raw_svg if @format == 'raw' content_type = 'image/svg+xml' encoding = 'charset=utf-8' data = CGI::escape(raw_svg).gsub('+', '%20') "<img src='data:#{content_type};#{encoding},#{data}' class='github-contributions' alt='#{@user} Github contributions' />" end |