class Addressable::Template

def expand_prefix_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_prefix_operator(argument, variables, mapping, partial=false)
  if variables.size != 1
    raise InvalidTemplateOperatorError,
      "Template operator 'prefix' takes exactly one variable."
  end
  value = mapping[variables.first]
  if !partial || value
    if value.kind_of?(Array)
      (value.map { |list_value| argument + list_value }).join("")
    elsif value
      argument + value.to_s
    end
  else
    "{-prefix|#{argument}|#{variables.first}}"
  end
end