Skip to content

Commit 6550c4c

Browse files
Update README.md
1 parent 34477f2 commit 6550c4c

File tree

1 file changed

+52
-2
lines changed

1 file changed

+52
-2
lines changed

README.md

Lines changed: 52 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,15 @@ curl -X POST -H "Content-Type: application/json" -H "Authorization: Bearer API_T
243243

244244
If you are not comfortable / don't want to hardcode your Number for example and/or Recipients in you, may use **Placeholders** in your Request.
245245

246-
You can use [**Variable**](#variables) `{{.NUMBER}}` Placeholders and **Body** Placeholders `{{@data.key}}`.
246+
**How to use:**
247+
248+
| Type | Example | Note |
249+
| :--------------------- | :------------------ | :--------------- |
250+
| Body | `{{@data.key}}` | |
251+
| Header | `{{#Content_Type}}` | `-` becomes `_` |
252+
| [Variable](#variables) | `{{.VAR}}` | always uppercase |
253+
254+
**Where to use:**
247255

248256
| Type | Example |
249257
| :---- | :--------------------------------------------------------------- |
@@ -373,6 +381,47 @@ If you are using Environment Variables as an example you won't be able to specif
373381
> If you have a string that should not be turned into any other type, then you will need to escape all Type Denotations, `[]` or `{}` (also `-`) with a `\` **Backslash** (or Double Backslash).
374382
> An **Odd** number of **Backslashes** **escape** the character in front of them and an **Even** number leave the character **as-is**.
375383

384+
### Templating
385+
386+
Secured Signal API uses Golang's [Standard Templating Library](https://pkg.go.dev/text/template).
387+
This means that any valid Go template string will also work in Secured Signal API.
388+
389+
Go's templating library is used in the following features:
390+
391+
- [Message Templates](#message-templates)
392+
- [Placeholders](#placeholders)
393+
394+
This makes advanced [Message Templates](#message-templates) like this one possible:
395+
396+
```yaml
397+
settings:
398+
messageTemplate: |
399+
{{- $greeting := "Hello" -}}
400+
{{ $greeting }}, {{ @name }}!
401+
{{ if @age -}}
402+
You are {{ @age }} years old.
403+
{{- else -}}
404+
Age unknown.
405+
{{- end }}
406+
Your friends:
407+
{{- range @friends }}
408+
- {{ . }}
409+
{{- else }}
410+
You have no friends.
411+
{{- end }}
412+
Profile details:
413+
{{- range $key, $value := @profile }}
414+
- {{ $key }}: {{ $value }}
415+
{{- end }}
416+
{{ define "footer" -}}
417+
This is the footer for {{ @name }}.
418+
{{- end }}
419+
{{ template "footer" . -}}
420+
------------------------------------
421+
Content-Type: {{ #Content_Type }}
422+
Redacted Auth Header: {{ #Authorization }}
423+
```
424+
376425
### API Token(s)
377426

378427
During Authentication Secured Signal API will try to match the given Token against the list of Tokens inside of these Variables.
@@ -454,7 +503,8 @@ settings:
454503
Sent with Secured Signal API.
455504
```
456505

457-
Use `{{@data.key}}` to reference Body Keys and `{{.KEY}}` for Variables.
506+
Message Templates support [Standard Golang Templating](#templating).
507+
Use `@data.key` to reference Body Keys, `#Content_Type` for Headers and `.KEY` for Variables.
458508

459509
### Data Aliases
460510

0 commit comments

Comments
 (0)