Class: Jekyll::Disqus::ScriptCounter

Inherits:
Liquid::Tag
  • Object
show all
Includes:
Helper
Defined in:
lib/jekyll/disqus/tags.rb

Overview

Print the Javascript code to render the counter.

Instance Method Summary collapse

Methods included from Helper

#disabled_tag?, #page_disqus_id, #post_disqus_id, #post_selector

Constructor Details

#initialize(tag_name, text, tokens) ⇒ ScriptCounter

Returns a new instance of ScriptCounter.



52
53
54
55
# File 'lib/jekyll/disqus/tags.rb', line 52

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

Instance Method Details

#render(context) ⇒ Object



57
58
59
60
61
62
63
64
# File 'lib/jekyll/disqus/tags.rb', line 57

def render(context)
  return "" if disabled_tag?("counter", context)

  "<script
    id=\"dsq-count-scr\"
    src=\"//#{context.registers[:site].config["jekyll-disqus"]["shortname"]}.disqus.com/count.js\"
    async></script>".gsub(/\n/, " ").gsub(/ +/, " ")
end