Advanced: Workshop
YAML
PixieBrix uses YAML, a human-friendly markup language, for defining bricks. To learn the basics of using YAML, view one of the following tutorials:
Dictionaries/Records
exampleProperty:
hello: 42
world: "this is a string!"Lists/Arrays
To create a list, use - below the parent entry:
exampleProperty:
- hello
- worldYou can also create a list of dictionaries. Note the indentation!
exampleProperty:
- propA: hello
propB: world
- propA: hello
propB: worldString Quoting Gotchas
There are several situations where you must surround a value with double quotes (") to ensure it’s interpreted as a string.
Namespaced Brick Ids
PixieBrix supports @user and @organization to namespace bricks. When using a namespaced brick id, you must surround the id in double quotes because @ is a reserved character in YAML
JQuery Selectors
Certain JQuery selectors must be enclosed in quotes so that they’re interpreted as strings:
"#id-selector": the id selector#is interpreted as starting a comment if not surrounded by quotes"[name='submit']": the attribute selector[is interpreted as a list if not surrounded by quotes
Templates
Templates are described in more detail below. Because they begin with a { if you don’t surround them in quotes they’re interpreted as a mapping
"{{ myVariable }}"
The exception is when writing multi-line strings using | you do not have to enclose them in quotes:
Variable references
In PixieBrix, variables and integration configurations referred to using a @ before their name. Because they start with a “@” you must enclose them in quotes.
Runtime API Version
The apiVersion directive controls how PixieBrix's runtime interprets the brick.
Whenever backward incompatible changes are introduced, we increment the apiVersion. If you do not specify the apiVersion, it defaults to v1
v1: our initial releasev2: made data flow between bricks explicit. Bricks had to reference data from previous bricks using the@outputKeyfor that brickv3(supported in the runtime, but not yet supported in the Page Editor). Uses explicit tags for!var,!mustache, and!nunjucks
Variables
You can provide a path, which also supports optional chaining:
Arrays are indexed using a numeric property:
Templating
PixieBrix supports a number of templating engines for wiring together bricks.
Nunjucks / jinja2
Nunjucks is a Javascript port of jinja2 supports logic including conditionals and mathematical expressions.
Brick Directives
Use the following brick directive when creating components and mods
Package Browser Extension Range
To set a minimum browser extension version, or allowed range, set the extensionVersion directive in the package metadata.
The extensionVersion directive supports a semantic version (SemVer) range:
When used with Mod Deployments, if the user's browser version does not meet the extension range, PixieBrix will prompt the user to update their extension. See Deploying Mods
Setting autofocus for inputs
If you want a form field to be autofocused so a user can start typing immediately, you'll need to add the ui:autofocus: true attribute to the field properties for the uiScehma in the workshop.
Example:
Last updated
Was this helpful?