class Jekyll::OEmbedPlugin
Public Class Methods
new(tag_name, text, tokens)
click to toggle source
Calls superclass method
# File lib/jekyll_oembed.rb, line 22 def initialize(tag_name, text, tokens) super @text = text end
Public Instance Methods
error_message(url)
click to toggle source
# File lib/jekyll_oembed.rb, line 47 def error_message(url) # Silent error. This seems preferable to a hard fail # because a user could make a URL private anytime. puts "OEmbedError: The url, #{url}, is not available as an oembed. " \ 'Consider using an HTML embed instead.'.red end
html_output(result)
click to toggle source
# File lib/jekyll_oembed.rb, line 42 def html_output(result) "<div class=\"embed-container #{result.fields['type']} " \ "#{result.fields['provider']}\">#{result.html}</div>" end
render(context)
click to toggle source
# File lib/jekyll_oembed.rb, line 27 def render(context) # Pipe param through liquid to make additional replacements possible url = Liquid::Template.parse(@text).render context url = url.strip! || url.strip begin # OEmbed look up result = ::OEmbed::Providers.get(url) html_output(result) rescue error_message(url) '' end end