Multi-line Strings
TON provides powerful multi-line string support with intelligent indentation processing.
Triple-Quoted Strings
Multi-line strings use triple quotes (single or double):
{
description = """
This is a multi-line string.
It can span multiple lines.
Indentation is intelligently handled.
""",
code = '''
function example() {
return "Hello World";
}
'''
}
Intelligent Indentation
TON automatically processes indentation in multi-line strings:
- Content boundaries are determined by triple quotes
- Common leading whitespace is identified and removed
- Relative indentation is preserved
- Empty lines are maintained
Example Processing
// Input
{
sql = """
SELECT u.id, u.name
FROM users u
WHERE u.active = true
"""
}
// Processed result (common indentation removed)
"SELECT u.id, u.name\nFROM users u\nWHERE u.active = true"
Use Cases
SQL Queries
queries = {
getUsers = """
SELECT u.id, u.name, u.email, p.bio
FROM users u
LEFT JOIN profiles p ON u.id = p.user_id
WHERE u.active = true
ORDER BY u.created_at DESC
"""
}
Code Snippets
examples = {
javascript = '''
const greet = (name) => {
console.log(\Hello, \!\);
};
greet("World");
'''
}
Documentation
api = {
description = """
## User Management API
This API provides endpoints for:
- Creating users
- Updating user profiles
- Managing permissions
All endpoints require authentication.
"""
}
Edge Cases
Empty Multi-line Strings
empty = """""" // Results in empty string
Strings with Special Characters
special = """
No escape sequences needed for:
- Quotes: " and '
- Backslashes: \
- Newlines are literal
"""
Best Practices
- Use triple quotes for any text spanning multiple lines
- Indent content naturally within your TON structure
- Let TON handle the indentation processing automatically
- Use single triple quotes for code, double for documentation