Module: PufferPages::Extensions::Liquid::Context

Extended by:
ActiveSupport::Concern
Defined in:
lib/puffer_pages/extensions/context.rb

Instance Method Summary collapse

Instance Method Details

#resolve_with_interpolation(key) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/puffer_pages/extensions/context.rb', line 11

def resolve_with_interpolation key
  if key.is_a? Symbol
    scope = @scopes.detect { |s| s.key? key }
    scope ||= @environments.detect { |s| s.key? key }
    scope[key] if scope
  else
    resolved = resolve_without_interpolation key
    if resolved.is_a?(String) && key =~ /^"(.*)"$/
      resolved.gsub!(/\#\{(.*?)\}/) do
        ::Liquid::Variable.new($1).render(self)
      end
    end
    resolved
  end
end