Empty conditionals

Check your values for empty strings, null or undefined values.

Conditionals syntax

Empty conditionals are defined with curly braces, a hash mark, and a key.

Inline conditionals

{#key} Hello World {/}
{#key.key} Hello World {/}

An space can be added between the braces and the key:

{ #key } Hello World {/}
{ #key.key } Hello World {/}

Block conditionals

{#key}
  Hello World
{/}
{#user.first_name}
  Hello {user.first_name}
{/}

Rendering

Define your values in the data object.

const data = {
  title: "Hello World",
  description: "A wonderful text",
  user: {
    first_name: "John",
    last_name: "Doe",
    city: "New York",
    age: 30,
    email: "[email protected]",
    website: "https://example.com",
  },
};

Render the document with the render method.

const templater = new OdtTemplater(content);
const renderedContent = templater.render(data);