# `Lotus.Variables`
[🔗](https://github.com/typhoonworks/lotus/blob/v0.16.6/lib/lotus/variables.ex#L1)

Utilities for Lotus `{{variable}}` template syntax.

Variables use the `{{name}}` placeholder format and can appear in SQL
queries, templates, or any other Lotus content type.

# `extract_names`

```elixir
@spec extract_names(String.t()) :: [String.t()]
```

Extracts variable names from a string containing `{{variable}}` placeholders.

Returns names in the order they appear, with duplicates preserved.

## Examples

    iex> Lotus.Variables.extract_names("WHERE id = {{user_id}} AND status = {{status}}")
    ["user_id", "status"]

    iex> Lotus.Variables.extract_names("no variables here")
    []

# `neutralize`

```elixir
@spec neutralize(String.t(), String.t()) :: String.t()
```

Replaces all `{{variable}}` placeholders with the given replacement value.

Useful for neutralizing variables before validation (e.g. replacing with
`"NULL"` for SQL syntax checking) or for any context where placeholders
need to be substituted with a static value.

## Examples

    iex> Lotus.Variables.neutralize("SELECT * FROM users WHERE id = {{user_id}}", "NULL")
    "SELECT * FROM users WHERE id = NULL"

    iex> Lotus.Variables.neutralize("Hello {{name}}", "")
    "Hello "

# `regex`

```elixir
@spec regex() :: Regex.t()
```

Returns the compiled regex for matching `{{variable}}` placeholders.

Captures the variable name (without braces) in group 1.

## Examples

    iex> Regex.scan(Lotus.Variables.regex(), "WHERE id = {{user_id}}")
    [["{{user_id}}", "user_id"]]

---

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