Conditionals
Conditionals syntax
Conditions are defined with curly braces, a hash mark, the key being checked, a double equal sign, and the value being compared.
Inline conditionals
{#key == value} Hello World {/}
{#key.key == value} Hello World {/}
An space can be added between the braces and the key:
{ #key == value } Hello World {/}
{ #key.key == value } Hello World {/}
Block conditionals
{#key == value}
Hello World
{/}
{#user.first_name == John}
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);