Class: Jekyll::BeforeAfterTag

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

Instance Method Summary collapse

Constructor Details

#initialize(tag_name, markup, tokens) ⇒ BeforeAfterTag

Returns a new instance of BeforeAfterTag.



17
18
19
20
# File 'lib/jekyll/before_after_tag.rb', line 17

def initialize(tag_name, markup, tokens)
  super
  @attributes = Jekyll.parse_ba_attrs(markup)
end

Instance Method Details

#render(context) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/jekyll/before_after_tag.rb', line 22

def render(context)
  before   = @attributes["before"]   || ""
  after    = @attributes["after"]    || ""
  orient   = @attributes["orientation"] || "horizontal"
  direction = orient == "vertical" ? ' direction="vertical"' : ""

  "    <img-comparison-slider\#{direction}>\n      <img slot=\"first\" src=\"\#{before}\" alt=\"Before\">\n      <img slot=\"second\" src=\"\#{after}\" alt=\"After\">\n    </img-comparison-slider>\n  HTML\nend\n"