Class: Jekyll::JamComments::Tag

Inherits:
Liquid::Tag
  • Object
show all
Defined in:
lib/jekyll_jam_comments.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(tag_name, path, tokens) ⇒ Tag

Returns a new instance of Tag.



12
13
14
15
16
# File 'lib/jekyll_jam_comments.rb', line 12

def initialize(tag_name, path, tokens)
  super

  @path = path
end

Instance Attribute Details

#markupObject (readonly)

Returns the value of attribute markup.



10
11
12
# File 'lib/jekyll_jam_comments.rb', line 10

def markup
  @markup
end

#pathObject (readonly)

Returns the value of attribute path.



10
11
12
# File 'lib/jekyll_jam_comments.rb', line 10

def path
  @path
end

Instance Method Details

#configurationObject



40
41
42
# File 'lib/jekyll_jam_comments.rb', line 40

def configuration
  Jekyll.configuration({})["jam_comments"]
end

#render(context) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
# File 'lib/jekyll_jam_comments.rb', line 18

def render(context)
  path = context["page"] && context["page"]["url"]
  markup = service.fetch(:path => path)

  "
    #{markup}
    <script>
      window.jcAlpine.start();
    </script>
  "
end

#serviceObject



30
31
32
33
34
35
36
37
38
# File 'lib/jekyll_jam_comments.rb', line 30

def service
  @service ||= Service.new(
    :domain      => Jekyll::JamComments::Configuration.domain,
    :api_key     => Jekyll::JamComments::Configuration.api_key,
    :base_url    => Jekyll::JamComments::Configuration.base_url,
    :environment => Jekyll::JamComments::Configuration.environment,
    :copy        => Jekyll::JamComments::Configuration.copy
  )
end