Class: Jekyll::BeforeAfterTag
- Inherits:
-
Liquid::Tag
- Object
- Liquid::Tag
- Jekyll::BeforeAfterTag
- Defined in:
- lib/jekyll/before_after_tag.rb
Instance Method Summary collapse
-
#initialize(tag_name, markup, tokens) ⇒ BeforeAfterTag
constructor
A new instance of BeforeAfterTag.
- #render(context) ⇒ Object
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"' : "" <<~HTML <img-comparison-slider#{direction}> <img slot="first" src="#{before}" alt="Before"> <img slot="second" src="#{after}" alt="After"> </img-comparison-slider> HTML end |