← All procedures

client.template

String interpolation with {{key}} placeholders

browsernot registered
Package
@procedures/client · README
Path
["client","template"]
CLI
Not a mark command: it is not in the default registry.
As data
{"$proc":["client","template"],"input":{}}
Tags
core, string

Try it in the Composer →

Use it

In TypeScript

import { Client, LocalTransport, PROCEDURE_REGISTRY, allCoreProcedures } from "@procedures/client";

for (const procedure of allCoreProcedures) {
  if (!PROCEDURE_REGISTRY.has(procedure.path)) PROCEDURE_REGISTRY.register(procedure);
}

const client = new Client(new LocalTransport({ registry: PROCEDURE_REGISTRY }));
const result = await client.exec(["client","template"], { template: "<template>", values: {} });
console.log(JSON.stringify(result));

As data, in a program

{
  "$proc": ["client", "template"],
  "input": { "template": "<template>", "values": {} }
}

Input

FieldTypeRequired
templatestringyes
valuesRecord<string, unknown>yes

Output

The schema does not list fields (string).

JSON Schemas
{
  "input": {
    "type": "object",
    "properties": {
      "template": {
        "type": "string",
        "description": "The template text, with {name} placeholders"
      },
      "values": {
        "type": "object",
        "propertyNames": {
          "type": "string"
        },
        "additionalProperties": {},
        "description": "The values"
      }
    },
    "required": [
      "template",
      "values"
    ]
  },
  "output": {
    "type": "string",
    "description": "The template with its placeholders filled"
  }
}