Referencing Variables
Variables are referenced using curly braces:System Variables
penscript provides built-in system variables available in every scope.| Variable | Description |
|---|---|
{$today} | The current date |
$ to distinguish them from user-defined data.
Inline Pipes
Variables support pipe expressions for inline transformations — lightweight operations applied directly inside a string reference, without needing a full JSON operator.Inline Comparisons & Ternaries
Simple logic can be expressed directly inside strings, without switching to JSON operators like:if or :cmp. This keeps lightweight conditions readable and compact.
Boolean comparisons:
:if or :case JSON operators instead.
Scope Resolution
When an expression references a variable, penscript resolves it by looking through the current scope. If a variable is not found, the reference resolves toundefined rather than throwing an error.
In nested contexts — like a :map loop inside a :define block — inner scopes can access variables from outer scopes. If a variable name exists in both the inner and outer scope, the inner scope takes precedence.
The full variable reference — all namespaces, every available key, and where each can be used — is documented in the Reference section.