This blog post recorded how I came up with the idea. You may jump to the GitHub repo directly, example usage is written there.
Everthing started from an old jQuery plugin
Recently I started to use Haxe as my primary programming language. I have always been thinking about what I can do with this modern language. Until I dug out an old jQuery plugin, which I wrote several years ago, while I was cleaning up some old files in my server. I remembered that it wasn’t easy to develop in javascript. It is because at that time there was no (or at least I was not aware of any) decent IDE for javascript. Even with the powerful debugger FireBug, which just began to gain popularity at that time, I still found it painful to debug javascript programs. Therefore I have stopped writing in javascript since then. Looking at the plugin’s forgotten to-do list and the unfinished next-version, I decided to find a way writing jQuery plugins (again) in Haxe.
Here is my goal to be done in Haxe:
- Register a function as a jQuery plugin by adding it to the jQuery.fn object
- Able to access the “this” object within the plugin function as in vanilla javascript
- The javascript output should be as simple and clean as possible
- Most important: Leverage Haxe’s feature such as Macros, Code-Completion, Compiler Checks to write a decent plugin