Skip to content

Instantly share code, notes, and snippets.

@manwithacat
Forked from joelverhagen/README.md
Last active August 29, 2015 14:26
Show Gist options
  • Select an option

  • Save manwithacat/231a95f1612ddaf933d5 to your computer and use it in GitHub Desktop.

Select an option

Save manwithacat/231a95f1612ddaf933d5 to your computer and use it in GitHub Desktop.
Jekyll Scribd Embed Plugin

Example use:

Easily embed a YouTube video.

{% youtube oHg5SJYRHA0 %}

You can also specify a height and width. If you do not, it defaults to 560 x 420.

{% youtube oHg5SJYRHA0 500 400 %}
module Jekyll
class YouTube < Liquid::Tag
Syntax = /^\s*([^\s]+)(\s+(\d+)\s+(\d+)\s*)?/
def initialize(tagName, markup, tokens)
super
if markup =~ Syntax then
@id = $1
if $2.nil? then
@width = 560
@height = 420
else
@width = $2.to_i
@height = $3.to_i
end
else
raise "No YouTube ID provided in the \"youtube\" tag"
end
end
def render(context)
"<iframe width=\"#{@width}\" height=\"#{@height}\" src=\"http://www.youtube.com/embed/#{@id}\" frameborder=\"0\" allowfullscreen=\"allowfullscreen\"></iframe>"
end
end
end
Liquid::Template.register_tag('youtube', Jekyll::YouTube)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment