Snippets Reference

Karl Falconer ·

The code editor ships with built-in snippets — templates you can expand by typing a keyword and pressing Tab. They cover the most common BGL patterns. This article is the full list.

To trigger a snippet: start typing the keyword on the left column. When the autocomplete dropdown shows the snippet (with the matching detail text), press Tab or Enter. The placeholders fill with ${name} syntax — press Tab to jump between them.

Structure

Trigger Detail Expands to
set an attribute to a value set ${var_or_attribute} to ${expression}
when true then do something when / true / then / (body) / end
for model collection for ${collection} in ${model} / (body) / end
default accept default accept ${model}
default reject default reject ${model}
add item to collection add ${number} item to ${collection} in ${model} block
print expression print ${}

Routing and fulfillment

Trigger Detail Expands to
route model to warehouse route ${model} to warehouse ${warehouse}
route model to warehouse and facility route ${model} to warehouse ${warehouse} / ${facility}
bundle items from multiple orders bundle ${model} using ${expression} waiting ${duration}
bundle items from multiple orders with sort bundle ${model} using ${expression} waiting ${duration} sequencing ${fields}
hold model until future time hold ${model} until @${period}
hold model for some duration hold ${model} waiting ${duration}
fail model fail ${model} with "${}"
archive model archive ${model}

Conditions

Trigger Detail Expands to
has items ${model} has ${any\|none\|all} ${collection} with ${}
\| regular expression capture \| /${prefix}(?<${variable}>.*)${suffix}/ matches ${expression}

Aggregation

Trigger Detail Expands to
accumulate numbers over a collection accumulate ${collection} in ${model} block with sum or count
accumulate numbers over an attribute that is a collection accumulate ${collection_attribute} block with sum or count
accumulate text over a collection accumulate ${collection} in ${model} block with join
accumulate text over an attribute that is a collection accumulate ${collection_attribute} block with join

Pattern matching

Trigger Detail Expands to
replace regular expression in text replace /${fragment}/ with "${replacement}" in ${text}
for text repetition for /(?<txt1>${pattern})/ in "${expression}" block
matches a number matches /\d+/
matches at least n digits matches /\d{${n},}/
matches abbreviation from a list of states matches /^(${AK}\|${AR})$/
matches repeated character between m and n times matches /${char}{${m},${n}}/
matches email address matches /^([a-zA-Z0-9._%-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,6})*$/
matches phone number a phone-number regex covering most international formats

Tips

  • Most patterns have a snippet. If you find yourself typing the same kind of statement repeatedly, check the autocomplete first — there’s probably a snippet for it.
  • Snippets are starting points, not finished code. They’re meant to be edited. The placeholders are hints about what each blank means.
  • Several keywords have multiple snippets. accumulate alone has four variants depending on whether you’re summing/counting/joining and whether you’re iterating over a model collection or an attribute. Pick the one whose detail text matches your case.
Was this article helpful?
0 out of 0 found this helpful

Comments

0 comments

Please sign in to leave a comment.