Class: Jekyll::UJVideoTag

Inherits:
Liquid::Tag
  • Object
show all
Includes:
Jekyll::UJPowertools::VariableResolver
Defined in:
lib/tags/video.rb

Constant Summary collapse

PLACEHOLDER =
"data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=="

Instance Method Summary collapse

Methods included from Jekyll::UJPowertools::VariableResolver

#is_quoted?, #parse_arguments, #parse_options, #resolve_input, #resolve_variable

Constructor Details

#initialize(tag_name, markup, tokens) ⇒ UJVideoTag

Returns a new instance of UJVideoTag.



11
12
13
14
# File 'lib/tags/video.rb', line 11

def initialize(tag_name, markup, tokens)
  super
  @markup = markup.strip
end

Instance Method Details

#render(context) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/tags/video.rb', line 16

def render(context)
  # Parse arguments
  args = parse_arguments(@markup)
  src_input = args[0]

  # Parse options and resolve their values
  options = parse_options(args[1..-1], context)

  # Resolve source path (treat unquoted strings as literals)
  src = resolve_input(context, src_input, true)
  return '' unless src

  # Check if this is an external URL
  is_external = !!(src =~ /^https?:\/\//)

  if is_external
    # For external URLs, just create a simple responsive video tag
    build_external_video(src, options)
  else
    # Extract file extension
    extension = File.extname(src)
    src_path = src.chomp(extension)

    # Determine max width
    max_width = options['max_width'] || options['max-width'] || false
    max_width = max_width.to_s if max_width

    # Build video element for local videos
    build_video_element(src, src_path, extension, max_width, options)
  end
end