Created
January 12, 2018 12:47
-
-
Save jeauxlb/817846ca22f96ef9f4f6303b99289ff3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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