class Addressable::Template

def expand_list_operator(argument, variables, mapping, partial=false)

Returns:
  • (String) - The expanded result.

Parameters:
  • mapping (Hash) -- The mapping of variables to values.
  • variables (Array) -- The variables the operator is working on.
  • argument (String) -- The argument to the operator.
def expand_list_operator(argument, variables, mapping, partial=false)
  if variables.size != 1
    raise InvalidTemplateOperatorError,
      "Template operator 'list' takes exactly one variable."
  end
  if !partial || mapping[variables.first]
    values = mapping[variables.first]
    if values
      if values.kind_of?(Array)
        values.join(argument)
      else
        raise InvalidTemplateOperatorError,
          "Template operator 'list' only accepts Array values."
      end
    end
  else
    "{-list|#{argument}|#{variables.first}}"
  end
end