Skip to main content
Glama
conditionals-ifif.md877 B
## Conditionals: `{#if}...{/if}` Basic conditional: Rust ``` let needs_validation = true; let code = ts_template! {     function save() {         {#if needs_validation}             if (!this.isValid()) return false;         {/if}         return this.doSave();     } }; ``` ### If-Else Rust ``` let has_default = true; let code = ts_template! {     {#if has_default}         return defaultValue;     {:else}         throw new Error("No default");     {/if} }; ``` ### If-Else-If Chains Rust ``` let level = 2; let code = ts_template! {     {#if level == 1}         console.log("Level 1");     {:else if level == 2}         console.log("Level 2");     {:else}         console.log("Other level");     {/if} }; ```

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/macroforge-ts/mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server