Expressions & Formatting
You don’t always need to build a custom tool to manipulate data. The Bridge provides built-in syntax for formatting strings, executing math, and branching logic inline.
1. String Interpolation
Section titled “1. String Interpolation”String interpolation allows you to seamlessly construct URLs, headers, or text fields using {...} placeholders.
Interpolation only works on the right-hand side of a Pull Wire (<-). The engine scans the string, resolves each placeholder at runtime, and concatenates the final result.
bridge Query.userOrders { with ordersApi as api with input as i with output as o
# Build a REST URL dynamically api.path <- "/users/{i.id}/orders"
# Assemble display text o.greeting <- "Hello, {i.firstName} {i.lastName}!"}Constant Wires vs. Pull Wires
Section titled “Constant Wires vs. Pull Wires”Be careful not to use the Constant Wire (=) operator if you want variables to resolve! Constant wires ignore placeholders completely.
o.path = "/users/{i.id}" # Literal string: "/users/{i.id}"o.path <- "/users/{i.id}" # Templated string: "/users/123"Coercion & Escaping
Section titled “Coercion & Escaping”Non-string values are automatically coerced into strings. null and undefined are safely converted into empty strings ("") to prevent "Hello, null" bugs.
If you need to include a literal curly brace in your string, escape it with a backslash: \{.
2. Inline Expressions (Math & Logic)
Section titled “2. Inline Expressions (Math & Logic)”You can perform arithmetic and comparison operations directly inside your wire assignments.
o.cents <- i.dollars * 100o.total <- i.price * i.quantityo.eligible <- i.age >= 18o.isActive <- i.status == "active"Supported Operators
Section titled “Supported Operators”| Category | Operators | Description |
|---|---|---|
| Arithmetic | *, /, +, - | Standard math operations. |
| Comparison | ==, !=, >, >=, <, <= | Returns boolean true or false. |
| Boolean | and, or, not | Logical operators for combining boolean values. |
Boolean Logic & Short-Circuiting
Section titled “Boolean Logic & Short-Circuiting”Use Python/SQL-style keywords for clear, unambiguous boolean expressions. These strictly evaluate to true or false.
and: Logical AND — returnstrueonly if both sides are truthy.or: Logical OR — returnstrueif either side is truthy.not: Logical NOT — inverts the value (prefix operator).(): Parentheses for grouping — overrides default operator precedence.
Lazy Evaluation: Boolean operators (and and or) use strict left-to-right short-circuiting. If the left side of an and evaluates to false, the right side is completely ignored. If the right side is an expensive API call, it is never executed.
# Inline policy evaluation with parentheses for groupingo.isApproved <- (i.age > 18 and i.verified) or i.role == "ADMIN"o.requireMFA <- not (i.isTrusted)
# Override precedence: add before multiplyo.total <- (i.price + i.discount) * i.qtyPrecedence and Chaining
Section titled “Precedence and Chaining”Standard operator precedence applies: multiplication/division bind tightest, then addition/subtraction, then comparisons, then and, and finally or binds loosest. Use parentheses () to override the default precedence when needed.
# Evaluates as: i.base + (i.tax * 2)o.total <- i.base + i.tax * 2
# Use parentheses to force addition first: (i.base + i.tax) * 2o.total <- (i.base + i.tax) * 2
# Evaluates as: (i.price * i.qty) > 100o.isExpensive <- i.price * i.qty > 100
# Without parens: (age > 18 and verified) or (role == "ADMIN")o.allowed <- i.age > 18 and i.verified or i.role == "ADMIN"
# With parens: age > 18 and (verified or role == "ADMIN")o.strict <- i.age > 18 and (i.verified or i.role == "ADMIN")3. Conditional Wires (? :)
Section titled “3. Conditional Wires (? :)”The conditional wire (ternary operator) allows you to select between two different sources based on a boolean condition.
# target <- condition ? true_branch : false_brancho.amount <- i.isPro ? i.proPrice : i.basicPriceThe condition can be a direct boolean reference (i.isPro), or a full inline expression (i.age >= 18). The branches can be tool references, input variables, or literal values ("premium", true, 20).
o.tier <- i.score > 100 ? "premium" : "basic"Lazy Evaluation
Section titled “Lazy Evaluation”Just like and/or logic, conditional wires are strictly evaluated. The engine evaluates the condition first. It then pulls data from only the chosen branch.
If the condition is false, the engine never touches the true branch. If that branch points to an expensive API call, the API is never called.
# If i.hasCustomData is false, the customDb API is completely ignored.o.data <- i.hasCustomData ? customDb.data : standardDb.data