Write a custom extension
Extension folder
An Extension is a folder with at least one JavaScript file inside. Extension folders should be placed in the Extensions/
folder and will be automatically detected and loaded by Paw. You can find the extension folder by going to the and hit the Open Extensions Directory
button.
You should first choose an Extension identifier, it should be a reverse domain name (for example, our Swift language code generator’s identifier is com.luckymarmot.PawExtensions.SwiftCodeGenerator
). The name of your extension folder must be the identifier.
Extension script
Inside this folder, you should have a JavaScript file named by the last component of the identifier (for our Swift language Code Generator, it is SwiftCodeGenerator.js
).
The Extension is represented by a JavaScript class. The class object should have these 2 properties:
identifier
: the Extension identifier (it should match the folder’s name)
title
: the name of your Extension (will be displayed to the user)
The rest of the implementation depends of the kind of Extension.
Code Generator
Code generators should have a generate(context, requests, options)
method.
Code generators register using the registerCodeGenerator()
function.
See Create a code generator
Importers
Importers should have an import(context, items, options)
method. This method should return true
when the import succeeded, and false
otherwise.
Importers register using the registerImporter()
function.
See Create an importer
Dynamic Values
Dynamic Values should have 3 methods:
evaluate(context)
evaluates the result of the Dynamic Value evaluation
title(context)
returns the title to show in the Dynamic Value Tokens
text(context)
returns the text to show in the Dynamic Value Tokens
An additional class property inputs
should be added.
See Create a dynamic value.