Fix #plugin
action not working in modern versions of Sketch
#286
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Getting this action working again is key to unlock workflows like this one: https://forum.sketch.com/t/populate-color-from-json-file/2465
P.S. The official documentation lacks practical examples so here's how the
#plugin
action is supposed to be used:Let's say you have the following plugin installed that you want to invoke on one of your template layers based on some condition:
Let's also assume that you have the following template layer structure:
Now, to invoke the plugin on the Rectangle layer, rename the latter as follows:
Notes
Your
{condition}
might be as simple as justtrue
(e.g.#plugin[true, My Plugin > My Action]
) if you want to always invoke the plugin no matter what's in your data. It may also reference other variables in your data: see examples.You may pass arguments to a plugin by including them in a layer name:
In order to access those arguments in your plugin, use the following:
As you can see, argument are passed to the plugin as an array of strings.