Snippets
Snippets are a feature of the Editor, and let you insert commonly-used patterns into your story with a single click. The editor provides two kinds: built-in snippets for frequent Squiffy and Handlebars patterns, and user-defined snippets you declare in your .squiffy file for patterns specific to your game.
Built-in snippets
Section titled “Built-in snippets”The Snippets dropdown button in the editor toolbar contains a set of ready-made templates for the most common patterns.
| Snippet | Inserts |
|---|---|
| If block | {{#if condition}}…{{/if}} |
| If/else block | {{#if condition}}…{{else}}…{{/if}} |
| If (check variable) | {{#if (eq (get "variable") "value")}}…{{/if}} |
| If (seen section) | {{#if (seen "section")}}…{{/if}} |
| Set variable | {{set "variable" "value"}} |
| Increment | {{inc "variable"}} |
| Decrement | {{dec "variable"}} |
| Section link | {{section "name" text="label"}} |
| Passage link | {{passage "name" text="label"}} |
| Embed | {{embed "name"}} |
Click a snippet to insert it at the current cursor position, then edit the placeholder values as needed.
User-defined snippets
Section titled “User-defined snippets”For patterns you use repeatedly in a particular game, you can define your own snippets directly in your .squiffy file using the [snippet: name]: syntax:
[snippet: Heal player]:{{inc "health"}}
[snippet: Quest complete]:{{set "quest_done" true}}{{inc "score"}}[[Quest completed]](questbook)User-defined snippets appear under My snippets in the Snippets dropdown, below the built-in snippets.
Placement
Section titled “Placement”Snippet blocks can appear anywhere in your file — before, between, or after sections. They don’t belong to any section or passage, and their content is ignored by the compiler.
[[intro]]:You wake up in a forest.
Your health is {{health}}.
[snippet: Heal player]:{{inc "health"}}
[snippet: Take damage]:{{dec "health"}}
[[clearing]]:You find a clearing.Example: health system
Section titled “Example: health system”Here’s an example with two user-defined snippets — Heal player and Take damage — alongside the sections that use them. The snippet definitions are stripped by the compiler; the {{inc}} and {{dec}} calls inside each passage are what was inserted from those snippets: