We're writing a bunch of .jsx scripts and in each I have to mock out some functions so I can use things like Array.map() and String.trim(), but I don't want to have to include that code at the top of every script.
Is there a way to "include" other .jsx scripts inside of a .jsx script file?
A script is a series of commands that tells an application to perform a series of operations. You can use scripts in most Adobe applications to automate repetitive tasks, perform complex calculations, and even use some functionality not directly exposed through the graphical user interface.
Because JSX files are plain text files, you can open them in any text editor, such as Microsoft Notepad (Windows) or Apple TextEdit (Mac). However, if you plan to edit a JSX file, you should open it in a source code editor, such as Microsoft Visual Studio (Windows) or Github Atom (cross-platform).
Or you can simply use #include
and #includepath
preprocessor directives at the top of your script.
You can find a detailed description in Adobe's "JavaScript Tools Guide".
For example, if you want to include scripts/helper.jsx
in a .jsx
file:
#include "scripts/helpers.jsx"
// the rest of your code below ...
Just leaving this here for anyone like me who is looking for this. In Adobe Illustrator CC 2015, I was unable to get #include
to work, but @include
did. So for example:
function alertTheWordNo(){
alert('NO');
}
//@include 'foo.jsx';
alertTheWordNo();
Disclaimer: I cannot find any documentation of this but have tested it with Adobe Illustrator CC 2015 and it works.
Hope this helps someone. If anyone has any questions just ask!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With