class SpotifyEmbed

Public Class Methods

new(tag_name, markup, tokens) click to toggle source
Calls superclass method
# File lib/jekyll-embeds.rb, line 113
def initialize(tag_name, markup, tokens)
  super
  params = Shellwords.shellwords markup
  @items = { :url => params[0] }
end

Public Instance Methods

render(context) click to toggle source
# File lib/jekyll-embeds.rb, line 119
def render(context)
  spotify_url = "#{@items[:url].strip}"

  if spotify_url[/open\.spotify\.com\/((embed\/?)?)([^\?]*)/]
    @spotify_id = $3
  else
    @spotify_id = "track/#{@items[:url]}"
  end
  %Q{<div class="embed-container"><iframe width="100%" height="166" scrolling="no" frameborder="no" src="//embed.spotify.com/?uri=#{@spotify_id}"></iframe></div>}
end