KartaWeb. API. V2. Replacements
(Karta v1.0.0)
The replacements of one recipient of a batch (POST /api/v2/messages/batch): {{name}} in the subject, the text or the HTML
becomes the recipient's value for name. Nothing else of a message is
replaced: not its addresses, header fields, tags, variables or
attachments.
- Names have 1 to 64 ASCII letters, digits,
_or-. Anything else between double braces ({{ name }},{{a.b}},{{}}) is not a placeholder and stays as written. - Plain substitution, in one pass. Nothing is evaluated: there are
no expressions, conditions, loops, filters or defaults. A value is
put in as a whole and never searched again, so a value that holds
{{other}}stays as written. - Every placeholder needs a value. A name the recipient has no value for is an error, never left as written or emptied, so that no message goes out half filled in.
- In the HTML a value is text: its
&,<,>,"and'become character references, so it can add no markup and cannot leave an attribute's quotes. In the text and the subject a value is put in as it is. - Control characters. A value may hold tabs and line breaks, no other control character. A value put into the subject may hold no line break either, so that it cannot end the Subject field and start another.
Summary
Functions
Checks the names and values of one recipient's replacements:
{:error, {:invalid_name, name}} or {:error, {:invalid_value, name}}
for the first problem, in the order of the names.
text (one part of a message, or nil) with its placeholders replaced
by values (checked with check/1). {:error, {:missing, name}} when a
placeholder has no value; {:error, {:line_break, name}} when a value
for the subject holds a line break or another control character.
Types
Functions
Checks the names and values of one recipient's replacements:
{:error, {:invalid_name, name}} or {:error, {:invalid_value, name}}
for the first problem, in the order of the names.
@spec replace(String.t() | nil, part(), values()) :: {:ok, String.t() | nil} | {:error, {:missing | :line_break, String.t()}}
text (one part of a message, or nil) with its placeholders replaced
by values (checked with check/1). {:error, {:missing, name}} when a
placeholder has no value; {:error, {:line_break, name}} when a value
for the subject holds a line break or another control character.