Ccna final exam - java, php, javascript, ios, cshap all in one. This is a collaboratively edited question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.
Wednesday, May 2, 2012
Integrating CoffeeScript with Eclipse?
Is there a way to integrate CoffeeScript and Eclipse, so that when I write CoffeeScript in one window the other will show the compiled code as Javascript?
I've done it with a builder and a small shell script in my project. Every time I save a .coffee file, it compiles all my scripts. Works great.
Right click on your project. Select properties near the bottom of the menu.
Builders New... Location: ${workspace_loc:/ProjectName/coffee-compile.sh} Working Directory: ${workspace_loc:/ProjectName} Refresh: Specify the folder where your generated .js files live. This allows you to keep the .js file open as well and it'll auto update when things re-compile. Build Options: Specify the folder where your .coffee files live.
ProjectName/coffee-compile.sh:
#!/bin/bash
if [ ! -d ./target/coffee ]; then mkdir -p ./target/coffee fi
The builder definition is saved as part of your project. It is in the .settings folder. That way, other developers can check out your project as well and have everything already set up.
Update: For code formatting and coloring, I ended up installing the latest beta of Aptana into Eclipse.
I'm using coffees -w option for this. Open a terminal, cd to your project directory and then run coffee -w ./coffee -c ./js. Assuming that your coffee files are stored in a folder named coffee and you are compiling your files to a folder named js.
Keep the terminal open while your coding session. coffee will compile your script every time you resave the file.
I've done it with a builder and a small shell script in my project. Every time I save a .coffee file, it compiles all my scripts. Works great.
ReplyDeleteRight click on your project. Select properties near the bottom of the menu.
Builders
New...
Location: ${workspace_loc:/ProjectName/coffee-compile.sh}
Working Directory: ${workspace_loc:/ProjectName}
Refresh: Specify the folder where your generated .js files live. This allows you to keep the .js file open as well and it'll auto update when things re-compile.
Build Options: Specify the folder where your .coffee files live.
ProjectName/coffee-compile.sh:
#!/bin/bash
if [ ! -d ./target/coffee ]; then
mkdir -p ./target/coffee
fi
echo "Compiling coffee script files..."
/usr/bin/coffee --output ./target/coffee --compile ./coffee
echo "Done..."
The builder definition is saved as part of your project. It is in the .settings folder. That way, other developers can check out your project as well and have everything already set up.
Update: For code formatting and coloring, I ended up installing the latest beta of Aptana into Eclipse.
I don't think so. You can use the 'TRY COFFEESCRIPT' button on http://jashkenas.github.com/coffee-script/ or the file system watcher (coffee -w).
ReplyDeleteI'm using coffees -w option for this. Open a terminal, cd to your project directory and then run coffee -w ./coffee -c ./js. Assuming that your coffee files are stored in a folder named coffee and you are compiling your files to a folder named js.
ReplyDeleteKeep the terminal open while your coding session. coffee will compile your script every time you resave the file.