solid v0.1.0 Solid.Argument

An Argument can be a field that will be inside the context or a value (String, Integer, etc)

Link to this section Summary

Functions

iex> Solid.Argument.get({:field, ["key"]}, %Solid.Context{vars: %{"key" => 123}}) 123 iex> Solid.Argument.get({:field, ["key1", "key2"]}, %Solid.Context{vars: %{"key1" => %{"key2" => 123}}}) 123 iex> Solid.Argument.get({:value, "value"}, %Solid.Context{}) "value" iex> Solid.Argument.get({:field, ["key"], [{:access, 1},{:access, 1}]}, %Solid.Context{vars: %{"key" => [1, [1,2,3], 3]}}) 2 iex> Solid.Argument.get({:field, ["key"], [{:access, 1}]}, %Solid.Context{vars: %{"key" => "a string"}}) nil

Link to this section Functions

Link to this function

get(arg, context)

get(
  {:field, [String.t()]}
  | {:field, [String.t()], [{:access, non_neg_integer()}]}
  | {:value, term()},
  Solid.Context.t()
) :: term()

iex> Solid.Argument.get({:field, ["key"]}, %Solid.Context{vars: %{"key" => 123}}) 123 iex> Solid.Argument.get({:field, ["key1", "key2"]}, %Solid.Context{vars: %{"key1" => %{"key2" => 123}}}) 123 iex> Solid.Argument.get({:value, "value"}, %Solid.Context{}) "value" iex> Solid.Argument.get({:field, ["key"], [{:access, 1},{:access, 1}]}, %Solid.Context{vars: %{"key" => [1, [1,2,3], 3]}}) 2 iex> Solid.Argument.get({:field, ["key"], [{:access, 1}]}, %Solid.Context{vars: %{"key" => "a string"}}) nil