# `Otera.Function`
[🔗](https://github.com/georgeguimaraes/otera/blob/v0.1.0/lib/otera/function.ex#L1)

An Elixir function with a Python signature, for a global, filter or test that takes keyword arguments.

    greet = Otera.Function.new("greet", ["name", {"punctuation", "!"}], fn name, punctuation ->
      "Hello, " <> name <> punctuation
    end)

    Otera.render("{{ greet('Ann', punctuation='?') }}", %{}, globals: %{"greet" => greet})
    #=> {:ok, "Hello, Ann?"}

A param is a name for a required argument, or `{name, default}`. Otera binds the positional and keyword arguments of a call to the params like a Python call, and calls `fun` with one value for each param. A wrong call raises the `TypeError` of Python, with `name` in the message. For a filter or a test, the first param is the value.

A plain Elixir function gets the positional arguments only.

# `param`

```elixir
@type param() :: String.t() | {String.t(), term()}
```

# `t`

```elixir
@type t() :: %Otera.Function{fun: function(), name: String.t(), params: [param()]}
```

# `new`

```elixir
@spec new(String.t(), [param()], function()) :: t()
```

Makes a function with the Python name `name` and the params `params`. `fun` takes one argument for each param.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
