Class: Jekyll::Spotify

Inherits:
Liquid::Tag
  • Object
show all
Defined in:
lib/spotify.rb

Instance Method Summary collapse

Constructor Details

#initialize(tag_name, id, tokens) ⇒ Spotify

Returns a new instance of Spotify.



18
19
20
21
# File 'lib/spotify.rb', line 18

def initialize(tag_name, id, tokens)
    super
    @id       = id
end

Instance Method Details

#render(context) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/spotify.rb', line 23

def render(context)
  @id, @width, @height = @id.split(' ').map(&:strip)

  if @width.nil? && @height.nil?
    @width = '100%'
    @height = '300'
  end

  if @id
    %(<iframe src=\"https://embed.spotify.com/?uri=#{@id}\" width=\"#{@width}\" height=\"#{@height}\" frameborder=\"0\" allowtransparency=\"true\" allow=\"encrypted-media\"></iframe>)
  else
    %(Error input, expected syntax: {% spotify id [width] [height] %})
  end
end