Debugging Templates
This guide helps you troubleshoot common template issues and understand what's happening with your data.
Common Issues
Variables Not Displaying
Symptom: {{variable}} appears as blank or the literal text {{variable}}
Causes and solutions:
-
Typo in variable name (case-sensitive)
-
Wrong path to nested data
-
Data not provided - Check your test JSON contains the expected property
-
Liquid syntax error - Missing closing braces or filter issues
Array Not Iterating
Symptom: {% for %} loop produces no output
Solutions:
-
Check if data is actually an array
-
Verify the path is correct
-
Check for empty array
Numbers Not Formatting
Symptom: format_number not working or showing unexpected results
Solutions:
-
Value might be a string - Convert first
-
Wrong format specifier
Dates Not Parsing
Symptom: parse_date returns nothing or wrong date
Solutions:
-
Check date format - European (DD/MM/YY) is default
-
Date might already be a date object - Try without
parse_date
Debugging Techniques
Inspect Data Structure
Use JSON output to see what data is available:
This shows the raw JSON structure, helping you verify paths.
Check Variable Type
Type: {{ variable | type }}
Size: {{ variable | size }}
Is Array: {% if isArray(variable) %}Yes{% else %}No{% endif %}
Debug with Conditionals
{% if customer %}
Customer exists: {{ customer.name }}
{% else %}
Customer is null/undefined
{% endif %}
{% if items.size > 0 %}
Has {{ items.size }} items
{% else %}
Items is empty
{% endif %}
tt_dumpData in Content Blocks
When using contentBlock(), the special placeholder {{tt_dumpData}} shows the data available to that content block:
This renders a <pre> tag with prettified JSON of the scoped data.
Note
{{tt_dumpData}} only works inside content blocks, not in the main template.
Step-by-Step Isolation
When a complex expression doesn't work, break it down:
<!-- Instead of this -->
{{ order.lines | map: "total" | sum | format_number: "C" }}
<!-- Try step by step -->
Lines: {{ order.lines | json }}
Totals: {{ order.lines | map: "total" | json }}
Sum: {{ order.lines | map: "total" | sum }}
Error Messages
"A value was expected at..."
A variable or expression is invalid at the specified position.
Check line 5, position 23 for: - Missing variable name - Invalid filter syntax - Unclosed brackets
"End of tag '}}' was expected at..."
Missing closing braces:
Template Validation
Use the API's validate endpoint or check in the editor. Syntax errors will be highlighted.
Testing Strategies
Start Simple
Begin with a minimal template and add complexity:
<!-- Step 1: Basic variable -->
{{ customer.name }}
<!-- Step 2: Add formatting -->
{{ customer.name | upcase }}
<!-- Step 3: Add conditional -->
{% if customer.isPremium %}Premium{% endif %}: {{ customer.name | upcase }}
Use Sample Data
Create minimal test JSON that covers your cases:
{
"customer": {
"name": "Test Customer",
"isPremium": true
},
"items": [
{ "name": "Item 1", "price": 10 },
{ "name": "Item 2", "price": 20 }
],
"emptyArray": [],
"nullValue": null
}
Test Edge Cases
- Empty arrays
- Null/missing values
- Zero values
- Very long strings
- Special characters
Performance Issues
Large Arrays
For arrays with 100+ items, consider:
- Pagination in your data source
- Using limit in for loops: {% for item in items limit:50 %}
Complex Nested Loops
Deeply nested loops can slow rendering:
<!-- Potentially slow with large datasets -->
{% for category in categories %}
{% for product in category.products %}
{% for variant in product.variants %}
...
{% endfor %}
{% endfor %}
{% endfor %}
Consider restructuring your data to flatten nested structures.
Getting Help
If you're stuck:
- Check this documentation for the feature you're using
- Verify your JSON structure matches your template expectations
- Test with minimal example that reproduces the issue
- Check the Liquid documentation for standard features
See Also
- Variables - Basic variable usage
- Data Binding - Working with JSON data
- Liquid Reference - Liquid syntax
- Filters & Tags - TemplateTo-specific features