<!-- Copyright (c) 2026 defconxt. All rights reserved. -->
<!-- Licensed under AGPL-3.0 — see LICENSE file for details. -->
<!-- NERF is a trademark of defconxt. -->
# Template Variables — API Reference

## Built-In Variables

| Variable | Description | Example Value |
|----------|-------------|---------------|
| `{{BaseURL}}` | Full URL with scheme | `https://example.com/path` |
| `{{RootURL}}` | Root URL without path | `https://example.com` |
| `{{Hostname}}` | Hostname only | `example.com` |
| `{{Host}}` | Hostname with port | `example.com:443` |
| `{{Port}}` | Port number | `443` |
| `{{Path}}` | URL path | `/path` |
| `{{Scheme}}` | Protocol scheme | `https` |
| `{{FQDN}}` | Fully qualified domain | `example.com` |

## Helper Functions

| Function | Return | Example |
|----------|--------|---------|
| `rand_int(min, max)` | int | `{{rand_int(1000, 9999)}}` |
| `rand_text_alpha(n)` | string | `{{rand_text_alpha(8)}}` |
| `rand_text_alphanumeric(n)` | string | `{{rand_text_alphanumeric(12)}}` |
| `rand_base(n, chars)` | string | `{{rand_base(6, "hex")}}` |
| `md5(str)` | string | `{{md5("test")}}` |
| `sha1(str)` | string | `{{sha1("test")}}` |
| `sha256(str)` | string | `{{sha256("test")}}` |
| `base64(str)` | string | `{{base64("payload")}}` |
| `base64_decode(str)` | string | `{{base64_decode("cGF5")}}` |
| `url_encode(str)` | string | `{{url_encode("<>")}}` |
| `url_decode(str)` | string | `{{url_decode("%3C")}}` |
| `hex_encode(str)` | string | `{{hex_encode("test")}}` |
| `hex_decode(str)` | string | `{{hex_decode("74657374")}}` |
| `unix_time()` | int | `{{unix_time()}}` |
| `to_lower(str)` | string | `{{to_lower("TEST")}}` |
| `to_upper(str)` | string | `{{to_upper("test")}}` |
| `trim(str, cut)` | string | `{{trim(body, " ")}}` |
| `env_var(name)` | string | `{{env_var("API_KEY")}}` |

## DSL Comparison Functions

| Function | Description |
|----------|-------------|
| `contains(str, substr)` | String contains check |
| `compare_versions(v1, expr)` | Semantic version comparison |
| `regex(str, pattern)` | Regex match test |
| `len(str)` | String or array length |
| `split(str, sep)` | Split string into array |
| `join(arr, sep)` | Join array into string |
| `replace(str, old, new)` | String replacement |

## Variable Override CLI

```bash
# Override single variable
nuclei -u https://target.com -t template.yaml -var api_key=abc123

# Override multiple variables
nuclei -u https://target.com -t template.yaml -var user=admin -var pass=test

# With environment variable
API_TOKEN=secret nuclei -u https://target.com -t template.yaml
```
