DEPRECATED
This code has been deprecated and is no longer maintained. The newest Titanium CLI tools make asynchronous compile hooks near impossible. Since a complete rewrite would be needed to become compatible with new versions of Titanium I opted to deprecate this in favor for pre-compile build tools such as gulp or grunt. I assume most coders who are using CoffeeScript have leveled up and can manage a build environment outside of Titanium Studio and no longer require the crutch of a compile hook such as this.
Anyone interested in rewriting this for the newer versions of Titanium can easily take over this project and remove the deprecation.
For an example of a gulp build using Titanium and CoffeeScript please check out this example project.
A CoffeeScript -> JavaScript compiler plugin for Titanium
This plugin has been tested with Titanium SDK 2.x and 3.1.x.
This project has been reborn from @billdawson’s version.
Apperson Labs has an excellent article on Titanium plugins.
How to use
This plugin will compile CoffeeScript files into JavaScript files using the following conventions:
- Any CoffeeScript files in the
src/
directory will compile to JavaScript into theResources/
directory. - Any CoffeeScript files in the
src/alloy/
directory will compile to JavaScript into theapp/
directory. - Any CoffeeScript files in the
app/
directory will compile to JavaScript into theapp/
directory.1
Installing
The plugin needs to be extracted to the correct location for the Titanium build system to find it. There are currently two places you can save this plugin: System or Project.
- Download an unzip the archive.
- Place the unzipped contents in one of the following location.
- Add a
<plugins>
entry to yourtiapp.xml
.
System
To make the plugin available for all your Titanium projects place the folder into your Titanium system plugins directory. This will be inside the Titanium SDK.
On Mac OS X this seems to be:
~/Application Support/Titanium/plugins
Project
To make this plugin available for a specific project you will have to remove the version directory from the archive. Unzip the archive and move all files and directories in ti.coffee/2.2
to ti.coffee
directory.
For example Titanium will look in your project root for the following directory structure to load this plugin:
|- :page_facing_up: tiapp.xml
|- :open_file_folder: Resources/
\- :open_file_folder: plugins/
\- :open_file_folder: ti.coffee/
|- :page_facing_up: plugin.py
|- :page_facing_up: cli.js
\- :open_file_folder: hooks/
\- :page_facing_up: plugin.js
If you don’t do this Titanium will ignore the plugin and never compile your CoffeeScript files.
tiapp.xml
To activate the plugin add an entry for it in your tiapp.xml
file:
<plugins>
<plugin version="2.2">ti.coffee</plugin>
</plugins>
-
This was to allow alloy only projects to keep source files coupled with their XML and TSS assets. ↩