Docs / Language & functions
a9script authoring pack — text functions
The text functions, with their arguments and a line of real script each. Called by bare name; nothing is imported. A call marked pauses does real work outside the script: the run is saved, and continues on the next line with the result.
slugify(text) — immediate
Turns a line of text into a slug that is safe in a URL or a file name: lower case, words joined by dashes, letters folded to plain Latin (é → e, ß → ss, ø → o) and everything else dropped.
text(string) — The text to convert. Only text — a number or a missing value is refused rather than turned into the slug of the word for it.
Answers: The slug. Text with nothing worth keeping — punctuation alone, an emoji — answers an empty string.
const slug = slugify(input.event.body.customer);
log("slug: " + slug);
template(text, values) — immediate
Fills {{key}} placeholders in a piece of text from an object of values. Nothing is escaped — the answer is plain text, so a value that has to be safe inside HTML or a URL must be made safe before it goes in.
text(string) — The text to fill.{{name}}marks a placeholder and spacing inside the braces is ignored; a single brace is ordinary text.values(object) — What to put in, looked up by key. Text, numbers and booleans are written out; a key the object does not carry, and a value that is null or missing, render as nothing; an object value is refused, since it has no sensible written form.
Answers: The filled text.
const note = template("Hi {{name}}, order {{id}} is on its way.", {
name: "Ada",
id: input.event.body.id
});
log(note);