Solid.Argument (solid v0.7.1)

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", 1, 1]], %Solid.Context{vars: %{"key" => [1, [1,2,3], 3]}}) 2 iex> Solid.Argument.get([field: ["key", 1]], %Solid.Context{vars: %{"key" => "a string"}}) nil iex> Solid.Argument.get([field: ["key", 1, "foo"]], %Solid.Context{vars: %{"key" => [%{"foo" => "bar1"}, %{"foo" => "bar2"}]}}) "bar2"

Link to this section Functions

Link to this function

get(arg, context, opts \\ [])

Specs

get(
  [{:field, [String.t() | integer()]}] | [{:value, term()}],
  Solid.Context.t(),
  Keyword.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", 1, 1]], %Solid.Context{vars: %{"key" => [1, [1,2,3], 3]}}) 2 iex> Solid.Argument.get([field: ["key", 1]], %Solid.Context{vars: %{"key" => "a string"}}) nil iex> Solid.Argument.get([field: ["key", 1, "foo"]], %Solid.Context{vars: %{"key" => [%{"foo" => "bar1"}, %{"foo" => "bar2"}]}}) "bar2"