-
Notifications
You must be signed in to change notification settings - Fork 0
Advanced templating SDK Support #8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
K-Kumar-01
wants to merge
39
commits into
main
Choose a base branch
from
ft/advanced_templating
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Signed-off-by: Kushal <[email protected]>
Signed-off-by: Kushal <[email protected]>
Signed-off-by: Kushal <[email protected]>
Signed-off-by: Kushal <[email protected]>
Signed-off-by: Kushal <[email protected]>
Signed-off-by: Kushal <[email protected]>
Signed-off-by: Kushal <[email protected]>
Signed-off-by: Kushal <[email protected]>
Signed-off-by: Kushal <[email protected]>
Signed-off-by: Kushal <[email protected]>
Signed-off-by: Kushal <[email protected]>
Signed-off-by: Kushal <[email protected]>
Signed-off-by: Kushal <[email protected]>
Signed-off-by: Kushal <[email protected]>
Signed-off-by: Kushal <[email protected]>
Signed-off-by: Kushal <[email protected]>
Signed-off-by: Kushal <[email protected]>
Signed-off-by: Kushal <[email protected]>
Signed-off-by: Kushal <[email protected]>
Signed-off-by: Kushal <[email protected]>
Signed-off-by: Kushal <[email protected]>
Signed-off-by: Kushal <[email protected]>
Signed-off-by: Kushal <[email protected]>
Signed-off-by: Kushal <[email protected]>
Signed-off-by: Kushal <[email protected]>
Signed-off-by: Kushal <[email protected]>
Signed-off-by: Kushal <[email protected]>
Signed-off-by: Kushal <[email protected]>
1d841f8 to
afb8ca8
Compare
Signed-off-by: Kushal <[email protected]>
Signed-off-by: Kushal <[email protected]>
Signed-off-by: Kushal <[email protected]>
Signed-off-by: Kushal <[email protected]>
Signed-off-by: Kushal <[email protected]>
Signed-off-by: Kushal <[email protected]>
Signed-off-by: Kushal <[email protected]>
Signed-off-by: Kushal <[email protected]>
Signed-off-by: Kushal <[email protected]>
Signed-off-by: Kushal <[email protected]>
Signed-off-by: Kushal <[email protected]>
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
No description provided.