Skip to content

Instantly share code, notes, and snippets.

@jeauxlb
Created January 12, 2018 12:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeauxlb/817846ca22f96ef9f4f6303b99289ff3 to your computer and use it in GitHub Desktop.
Save jeauxlb/817846ca22f96ef9f4f6303b99289ff3 to your computer and use it in GitHub Desktop.
class Video < Liquid::Tag
Syntax = /^\s*([^\s]+)(\s+(\d+)\s+(\d+)\s*)?/
def initialize(tagName, markup, tokens)
super
@url = Jekyll.configuration({})['url'] || 'http://example.com'
if markup =~ Syntax then
@id = $1
if $2.nil? then
@width = 560
@height = 420
else
@width = $2.to_i
@height = $4.to_i
end
else
raise "No Video Source provided"
end
end
def lookup(context, name)
lookup = context
name.split(".").each { |value| lookup = lookup[value] }
lookup
end
def render(context)
#"<iframe width=\"#{@width}\" height=\"#{@height}\" src=\"#{@base_url}/#{@id}\" ></iframe>"
"<iframe width=\"#{@width}\" height=\"#{@height}\" src=\"#{@id}\" ></iframe>"
end
Liquid::Template.register_tag "Video", self
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment