lib/garcon/utility/interpolation.rb
# Provides recursive interpolation of node objects, using standard
# string interpolation methods.
#
# @param [String] item
#   The string to interpolate.
#
# @param [String, Hash] parent
#   The string used for substitution.
#
# @return [String]
#
# @api private
Provides recursive interpolation of node objects, using standard
string interpolation methods.
Provides recursive interpolation of node objects using standard string interpolation methods .
def render(item, parent = nil)
      item = item.to_hash if item.respond_to?(:to_hash)
      if item.is_a?(Hash)
        item = item.inject({}) { |memo, (k,v)| memo[sym(k)] = v; memo }
        item.inject({}) {|memo, (k,v)| memo[sym(k)] = render(v, item); memo}
      elsif item.is_a?(Array)
        item.map { |i| render(i, parent) }
      elsif item.is_a?(String)
        item % parent rescue item
      else
        item
      end
    end
def render ( item , parent = nil ) item = item . to_hash if item . respond_to? ( :to_hash ) if item . is_a? ( Hash ) item = item . inject ( { } ) { | memo , ( k , v ) | memo [ sym ( k ) ] = v ; memo } item . inject ( { } ) { | memo , ( k , v ) | memo [ sym ( k ) ] = render ( v , item ) ; memo } elsif item . is_a? ( Array ) item . map { | i | render ( i , parent ) } elsif item . is_a? ( String ) item % parent rescue item else item end end
Provides recursive interpolation of node objects, using standard
string interpolation methods.
Provides recursive interpolation of node objects using standard string interpolation methods .
None
String
item
<not_specific>
parent
<not_specific>
<not_specific>
parent The string used for substitution.
parent The string used for substitution .
api
None