Disclaimer
If you already style your own code as you write it then you don't really need this unless you frequently find yourself styling other people's code. I.e: Forum helpers such as myself.
The Problem
If your code looks like this when you post it:
PHP Code:
//#CLIENTSIDE
function onCreated() {
if(etc){
dostuff();
}
else
{
youneedthis();
}
}
You need to beautify/style your code before anyone else will be able to understand and read it properly. Readable code makes it much easier for others who want to help you.
After running it through the beautifier you're left with this:
PHP Code:
//#CLIENTSIDE
function onCreated() {
if (etc) {
dostuff();
} else {
youneedthis();
}
}
As you learn how to script and program, you'll also get into the habit of indenting and styling your own code as you write but until then you can just use the GS2 Beautifier before posting/sharing your code.
The Quick Fix
After witnessing an issue caused by the jsbeautifier.org and actual GS2 code I have forked the project, and modified it to properly support the following:
- public functions
- //#CLIENTSIDE
- Concatenation Symbols: @=, @, SPC, NL, TAB
I've also changed the default settings on the site to the style most experienced scripters use:
- Indent with two spaces
- Braces with control statements
PHP Code:
//#CLIENTSIDE
function onCreated() {
echo("This is how it styles it...");
}
Instructions
1. Go to
http://fp4.ca/gs2beautifier
2. Paste your code into the box
3. Click 'Beautify GS2'