spz-action-macro

When to use

spz-action-macro allows you to create reusable action sequences and control their execution order.

Supported layout

  • logic

Usage

Each action macro needs an id and an arguments definition. You can call the macro by its id and pass arguments that alter its behavior.

<spz-carousel id="carousel" ...>...</spz-carousel>
<spz-action-macro
  id="carousel-macro"
  execute="carousel.goToSlide(index=foo), carousel.goToSlide(index=bar)"
  arguments="foo, bar"
></spz-action-macro>
<button @tap="carousel-macro.execute(foo=1, bar=2)">
  Go to slide 1 then 2
</button>

Attributes

AttributeDescriptionTypeRequired
idUnique identifier for the macro. Referenced when invoking the macro actionstringYes
argumentsComma-separated argument variable names that can be substituted in the action expressionstringNo

Actions

execute

Execute the macro's action expression. The execute attribute on the element defines the action(s) to run, with argument placeholders substituted by the values passed during invocation.

Parameters: Defined by the arguments attribute. Each argument name becomes a named parameter.

Example:

<spz-action-macro
  id="my-macro"
  execute="target.show;target2.toggleClass(class=foo)"
  arguments="foo"
></spz-action-macro>
<button @tap="my-macro.execute(foo='highlight')">Run macro</button>

Notes

  • The execute attribute defines the action expression template, not an action itself.
  • This component does not emit custom events.