1
0
Fork 0
freesewing/markdown/dev/reference/macros/en.md
2022-09-30 15:34:59 +02:00

1.1 KiB

title
Macros

Macros are a way to combine different operations into a single command. Macros are typically provided by by plugins, but can also be added ad-hoc without the need for a plugin.

Signature

null macro(object config, object props)

A macro receives a single configuration object as its first parameter. The second parameter is the same object received by the draft method in a part

Example

pattern.use({
  name: 'My adhoc plugin',
  macros: {
    myMacro: function (so, props) {
      // Do something wonderful here
    },
    myOtherMacro: function (so, props) {
      // Do something wonderful here
    },
  }
}

Now you can use these macros in your part:

({ macro, part }) => {

  macro('myMacro', {
    some: [ 'config', 'here' ],
    more: 'config'
  })
  macro('myOtherMacro', 'Just a string')

  return part
}

Macros we maintain

Below is a list of macros from the plugins we maintain:

Notes

We recommend allowing to undo a macro by passing false as its parameter.