From c21228c35848d86b7487b27eb632128ecac5fee4 Mon Sep 17 00:00:00 2001 From: thienbao860 <35884937+thienbao860@users.noreply.github.com> Date: Mon, 11 Jan 2021 17:18:45 +0700 Subject: [PATCH] Updated Your First Script (markdown) --- Your-First-Script.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Your-First-Script.md b/Your-First-Script.md index a46a901..18467ea 100644 --- a/Your-First-Script.md +++ b/Your-First-Script.md @@ -1,6 +1,6 @@ ## Creating Your Script -JavaScript-Expansions are all written in JavaScript (as the name implies). +JavaScript-Expansions scripts are all written in JavaScript coding language (as the name implies). Here is an example "Hello, world!" script: @@ -13,22 +13,24 @@ helloWorld(); ``` As you can see, the scripts return one value. - +**NOTE: ** Semicolons (`;`) are not required in JS language. However, this is required with multiple statements stacked in 1 line of script ## Using Your Script To use our hello_world script, first let's save the above as `hello_world.js` inside the `plugins/PlaceholderAPI/javascripts/` folder. Next, add it to the `plugins/PlaceholderAPI/javascript_placeholders.yml` file so the expansion knows to load it! +Specifying script engine is optional, as it will be defaulted to 'nashorn' if not initialized ```YAML hello_world: file: hello_world.js + engine: nashorn #optional, can be deleted ``` -Then, after reloading PlaceholderAPI plugin (`/papi reload`) you can use your placeholder! +Then, after reloading with JS-Expansion command (`/jsexpansion reload`) or PlaceholderAPI plugin (`/papi reload`), you can use your placeholder! -To test it, run `/papi parse me %javascript_hello_world%` +To test it, run `/papi parse me %javascript_hello_world%` (doesn't work in console) And ta-da! ![example](https://i.imgur.com/1RdtmUR.png)