Class: Liquify::Parameter

Inherits:
Array
  • Object
show all
Defined in:
lib/liquify/parameter.rb

Instance Method Summary collapse

Constructor Details

#initialize(markup, context = {}) ⇒ Parameter



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/liquify/parameter.rb', line 3

def initialize(markup, context={})
  markup = markup.split(',')
  args = []
  options = {}

  markup.each do |arg|
    key, value = arg.split(':')
    key = strip_quotes(key.strip)

    if value
      value = (value =~ /("|')/) ? strip_quotes(value.strip) : context[value.strip]
      options[key] = value
    else
      args << key
    end
  end
  args << options unless options.empty?

  super(args)
end

Instance Method Details

#extract_options!Object



25
26
27
# File 'lib/liquify/parameter.rb', line 25

def extract_options!
  last.is_a?(Hash) ? pop : {}
end