Top Level Namespace

Defined Under Namespace

Modules: Jekyll, JekyllVersionHelper

Instance Method Summary collapse

Instance Method Details

#iterate(h, variables) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/configurer.rb', line 3

def iterate(h, variables)
  h.each do |k, v|
    # If v is nil, an array is being iterated and the value is k.
    # If v is not nil, a hash is being iterated and the value is v.
    #
    value = v || k

    if value.is_a?(Hash) || value.is_a?(Array)
      iterate(value, variables)
    else
      variables.each_pair { |var, val| v.gsub!(/\%\{#{var}\}/, val) } if v.is_a? String
    end
  end
end