-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# @n8n/tournament | ||
|
||
Tournament is an output-compatible rewrite of [`riot-tmpl`](https://github.com/riot/tmpl) for template expression evaluation. | ||
|
||
## Installation | ||
|
||
```sh | ||
pnpm add @n8n/tournament | ||
``` | ||
|
||
## Features | ||
|
||
- Compatible with `riot-tmpl` expressions | ||
- ES6 syntax support, e.g. arrow functions and template literals | ||
- Built-in AST hooks for expression manipulation | ||
- TypeScript support | ||
|
||
## Usage | ||
|
||
```ts | ||
import { Tournament } from '@n8n/tournament'; | ||
|
||
const tournament = new Tournament(); | ||
|
||
// simple expressions | ||
tournament.execute('{{ 1 + 2 }}', {}); // 3 | ||
|
||
// with data context | ||
tournament.execute('{{ user.name }}', { user: { name: 'John' } }); // 'John' | ||
|
||
// template strings | ||
tournament.execute('{{ `Hello ${user.name}!` }}', { user: { name: 'John' } }); // 'Hello John!' | ||
|
||
// error handling | ||
const tournament = new Tournament((error) => { | ||
console.error('Expression error:', error); | ||
}); | ||
``` |