UNPKG

@macroforge/mcp-server

Version:

MCP server for Macroforge documentation and code analysis

55 lines (44 loc) • 4.04 kB
## Quick Reference | Syntax | Description | | -------------------------------------------------------------- | --------------------------------------------------------------------------------------- | | `@{expr}` | Interpolate a Rust expression (adds space after) | | `{&#124; content &#124;}` | Ident block: concatenates without spaces (e.g., `{&#124;get@{name}&#124;}` → `getUser`) | | `{> "comment" <}` | Line comment: outputs `// comment` (string preserves whitespace) | | `{>> "doc" <<}` | Block comment: outputs `/* comment */` (string preserves whitespace) | | `@@{` | Escape for literal `@{` (e.g., `"@@{foo}"` → `@{foo}`) | | `"text @{expr}"` | String interpolation (auto-detected) | | `"'^template ${js}^'"` | JS backtick template literal (outputs `` `template ${js}` ``) | | `{#if cond}...{/if}` | Conditional block | | `{#if cond}...{:else}...{/if}` | Conditional with else | | `{#if a}...{:else if b}...{:else}...{/if}` | Full if/else-if/else chain | | `{#if let pattern = expr}...{/if}` | Pattern matching if-let | | `{#match expr}{:case pattern}...{/match}` | Match expression with case arms | | `{#for item in list}...{/for}` | Iterate over a collection | | `{#while cond}...{/while}` | While loop | | `{#while let pattern = expr}...{/while}` | While-let pattern matching loop | | `{$let name = expr}` | Define a local constant | | `{$let mut name = expr}` | Define a mutable local variable | | `{%let name = expr}` | Bind a Rust variable (alternate syntax for `{$let}`) | | `{$do expr}` | Execute a side-effectful expression | | `{$typescript stream}` | Inject a TsStream, preserving its source and runtime\_patches (imports) | **Note:** A single `@` not followed by `{` passes through unchanged (e.g., `email@domain.com` works as expected). ## Interpolation: `@{expr}` Insert Rust expressions into the generated TypeScript: Rust ``` let class_name = "User"; let method = "toString"; let code = ts_template! {     @{class_name}.prototype.@{method} = function() {         return "User instance";     }; }; ``` **Generates:** TypeScript ``` User.prototype.toString = function () {   return "User instance"; }; ```