class YouTubeEmbed
Public Class Methods
new(tagName, text, tokens)
click to toggle source
Calls superclass method
# File lib/jekyll-html5-youtube.rb, line 6 def initialize(tagName, text, tokens) super @text = text end
Public Instance Methods
render(context)
click to toggle source
# File lib/jekyll-html5-youtube.rb, line 11 def render(context) youtube_url = "#{context[@text.strip]}" if youtube_url[/youtu\.be\/([^*]*)/] @youtube_id = $1 else youtube_url[/^.*((v\/)|(embed\/)|(watch\?))\??v?=?([^\*]*).*/] @youtube_id = $5 end includes_path = File.join Dir.pwd, "_includes", "youtube.html" if File.exist?(includes_path) includes = File.read includes_path site = context.registers[:site] includes = (Liquid::Template.parse includes).render site.site_payload.merge!({"youtube_id" => @youtube_id}) else %Q{<div class='embed-container'>\n<object data="https://www.youtube.com/embed/#{ @youtube_id }"></object>\n</div>} end end