Skip to content

Conversation

@K-Kumar-01
Copy link
Collaborator

No description provided.

@K-Kumar-01 K-Kumar-01 force-pushed the ft/advanced_templating branch from 1d841f8 to afb8ca8 Compare January 25, 2026 10:00
Comment on lines +202 to +212
result = await TurboTemplate.generate(
template_id=TEMPLATE_ID,
variables=[
{"placeholder": "{customer_name}", "name": "customer_name", "value": "John Doe", "mimeType": "text"},
{"placeholder": "{order_total}", "name": "order_total", "value": 1500, "mimeType": "text"},
{"placeholder": "{order_date}", "name": "order_date", "value": "2024-01-01", "mimeType": "text"},
],
name="Simple Substitution Document",
description="Basic variable substitution example",
output_format="pdf",
)
Comment on lines +226 to +248
result = await TurboTemplate.generate(
template_id=TEMPLATE_ID,
variables=[
{
"placeholder": "{user}",
"name": "user",
"value": {
"name": "John Doe",
"email": "[email protected]",
"profile": {
"company": "Acme Corp",
"title": "Software Engineer",
"location": "San Francisco, CA"
}
},
"mimeType": "json",
"usesAdvancedTemplatingEngine": True,
},
],
name="Nested Objects Document",
description="Nested object with dot notation example",
output_format="pdf",
)
Comment on lines +265 to +283
result = await TurboTemplate.generate(
template_id=TEMPLATE_ID,
variables=[
{
"placeholder": "{items}",
"name": "items",
"value": [
{"name": "Item A", "quantity": 5, "price": 100, "sku": "SKU-001"},
{"name": "Item B", "quantity": 3, "price": 200, "sku": "SKU-002"},
{"name": "Item C", "quantity": 10, "price": 50, "sku": "SKU-003"},
],
"mimeType": "json",
"usesAdvancedTemplatingEngine": True,
},
],
name="Array Loops Document",
description="Array loop iteration example",
output_format="pdf",
)
Comment on lines +300 to +309
result = await TurboTemplate.generate(
template_id=TEMPLATE_ID,
variables=[
{"placeholder": "{is_premium}", "name": "is_premium", "value": True, "mimeType": "json", "usesAdvancedTemplatingEngine": True},
{"placeholder": "{discount}", "name": "discount", "value": 0.2, "mimeType": "json", "usesAdvancedTemplatingEngine": True},
],
name="Conditionals Document",
description="Boolean conditional example",
output_format="pdf",
)
Comment on lines +323 to +332
result = await TurboTemplate.generate(
template_id=TEMPLATE_ID,
variables=[
{"placeholder": "{title}", "name": "title", "value": "Quarterly Report", "mimeType": "text"},
{"placeholder": "{logo}", "name": "logo", "value": "https://example.com/logo.png", "mimeType": "image"},
],
name="Document with Images",
description="Using image variables",
output_format="pdf",
)
- Boolean/number values with mimeType: 'json' work for conditionals
"""

import asyncio
*
* Template: "Dear {firstName}, your email is {simpleEmail}."
*/
async function simpleSubstitution() {
*
* Template: "Name: {user.firstName}, Email: {user.email}"
*/
async function nestedObjects() {
*
* Template: "Team Lead: {company.divisions.engineering.teamLead.name}"
*/
async function deepNestedObjects() {
* - {name}: ${price}
* {/products}
*/
async function loopsAndArrays() {
* {#isActive}User is active{/isActive}
* {^isActive}User is inactive{/isActive}
*/
async function conditionals() {
*
* Template: "Total: {price + tax}", "Result: {a + b}"
*/
async function expressionsAndCalculations() {
*
* Template: "Final: {basePrice * quantity + shipping - discount}"
*/
async function complexExpressions() {
*
* Template: "Item Total: {item.price * item.quantity}"
*/
async function objectPropertyExpressions() {
* {/employees}
* {/departments}
*/
async function nestedLoops() {
* - {productName}: ${itemPrice} {#isOnSale}(ON SALE!){/isOnSale}
* {/orderItems}
*/
async function conditionalsInLoops() {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants