Class: Jekyll::ImgflowTag

Inherits:
Liquid::Tag
  • Object
show all
Defined in:
lib/jekyll-imgflow/imgflow_tag.rb

Instance Method Summary collapse

Constructor Details

#initialize(tag_name, markup, tokens) ⇒ ImgflowTag

Returns a new instance of ImgflowTag.



5
6
7
8
# File 'lib/jekyll-imgflow/imgflow_tag.rb', line 5

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

Instance Method Details

#render(context) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/jekyll-imgflow/imgflow_tag.rb', line 10

def render(context)
  # Get components
  components = get_imgflow_components(context)

  # Check if markup contains preset
  markup_to_parse = if @markup.include?("preset:")
                      # Route through PresetManager: preset → tags:value → Parser
                      expand_preset_markup(@markup, components[:preset_manager])
                    else
                      # Direct route: markup → Parser
                      @markup
                    end

  # Use central parser to parse markup (uniform for both paths)
  parsed = JekyllImgFlow::Parser.parse(markup_to_parse, context)

  # Process operations through the new architecture
  process_operations(components, parsed, context)
rescue StandardError => e
  # Handle errors gracefully - don't crash the build for one image
  Jekyll.logger.error "ImgFlow Error: #{e.message}"
  Jekyll.logger.debug "ImgFlow Backtrace: #{e.backtrace.first(5).join("\n")}"
  "<!-- ImgFlow Error: #{e.message} -->"
end