Display Text Template
When a document needs to be shown or referenced in the UI, a text representation is required. By default, Charon will use one of the following properties, in order of precedence: DisplayName
, Name
, Title
, or Id
. This fallback behavior can often result in uninformative or unclear document labels.
For example, consider the following document:
{
"Id": 1,
"Description": "Bring 40 wolf skins",
"Type": "RepeatableQuest",
"Tasks": [ /* ... */ ]
}
By default, this document would be displayed in UI lists simply as "1"
. This can be improved by defining a custom Display Name Template for the Schema.
For instance, the template:
Quest #{Id}: {Type} - {Description}
would render the document’s label as:
Quest #1: RepeatableQuest - Bring 40 wolf skins
Template Syntax
The display name template is a string that may include replaceable expressions enclosed in curly braces ({}
). These expressions support a subset of C-style syntax and can reference any top-level or nested property of the document.
Property Access
Top-level properties can be accessed directly by name.
Nested properties in embedded documents can be accessed using dot notation, e.g.,
Item.Name
.
Supported Data Types
Type |
Example |
---|---|
String |
|
Number |
|
Boolean |
|
null |
|
Unary Operators
Operator |
Example |
---|---|
Logical NOT |
|
Bitwise Complement |
|
Negation |
|
Binary Operators
The following binary expressions are supported:
Operator |
Example |
---|---|
Subtract |
|
Add |
|
Concatenate |
|
Division |
|
Multiplication |
|
Power |
|
Modulo |
|
Bitwise AND |
|
Bitwise OR |
|
Bitwise XOR |
|
Bitwise Left Shift |
|
Bitwise Right Shift |
|
Logical AND (short-circuit) |
|
Logical OR (short-circuit) |
|
Greater Than |
|
Greater Than or Equal |
|
Less Than |
|
Less Than or Equal |
|
Equal To |
|
Not Equal To |
|
Coalesce |
|
Ternary Operator
Ternary expressions are supported using the standard syntax:
{Damage >= 0 ? "Total Damage" : "Total Heal"}: {Damage}
This will result in either “Total Damage: X” or “Total Heal: X”, depending on the value of Damage
.
Operator Precedence
You can control expression evaluation order using parentheses. For example:
Max Damage: {BaseDamage * (BaseCriticalChance + BonusCriticalChance)}