class Addressable::Template

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