Class: Koziolekweb::Tags::YtVideo

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

Instance Method Summary collapse

Constructor Details

#initialize(tag_name, video_id, tokens) ⇒ YtVideo

Returns a new instance of YtVideo.



86
87
88
89
90
91
92
93
94
# File 'lib/jekyll/koziolekweb/tags.rb', line 86

def initialize(tag_name, video_id, tokens)
  super
  @video_id = video_id.strip

  if @video_id.empty? || !valid_video_id?(@video_id)
    raise Liquid::SyntaxError, "Invalid video ID: #{@video_id.inspect}"
  end

end

Instance Method Details

#render(_context) ⇒ Object



96
97
98
99
100
101
102
# File 'lib/jekyll/koziolekweb/tags.rb', line 96

def render(_context)
  "    <div class=\"video\">\n      <iframe title=\"Youtube Video\" src=\"https://www.youtube-nocookie.com/embed/\#{@video_id}\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" allowfullscreen></iframe>\n    </div>\n  HTML\nend\n"