Class: Jekyll::Favicon::Tag

Inherits:
Liquid::Tag
  • Object
show all
Defined in:
lib/jekyll/favicon/tag.rb

Overview

New ‘favicon` tag for favicon include on templates

Instance Method Summary collapse

Constructor Details

#initialize(tag_name, text, tokens) ⇒ Tag

Returns a new instance of Tag.



5
6
7
8
# File 'lib/jekyll/favicon/tag.rb', line 5

def initialize(tag_name, text, tokens)
  super
  @text = text
end

Instance Method Details

#render(context) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/jekyll/favicon/tag.rb', line 10

def render(context)
  site = context.registers[:site]
  prepend_path = site.baseurl || ''
  templates_dir = Favicon.templates
  head = "<!-- Begin Jekyll Favicon tag v#{Favicon::VERSION} -->"
  body = %w[classic safari chrome ie].collect do |template|
    template_path = File.join templates_dir, "#{template}.html.erb"
    ERB.new(File.read(template_path), nil, '-').result(binding).strip
  end
  foot = '<!-- End Jekyll Favicon tag -->'
  [head, body.join("\n"), foot].join("\n")
end