coffeeich / caffeine

Caffeine extends CoffeeScript.
https://github.com/coffeeich/caffeine
MIT License
22 stars 5 forks source link

caffeine features? #3

Open mark-hahn opened 8 years ago

mark-hahn commented 8 years ago

Are there docs anywhere for the differences between this and coffee?

ghost commented 8 years ago

Hi! There is no docs yet, but "how to use" is in readme.md. In few words main differences are:

Code as example

Make dir sub/dir and files A.coffee, B.coffee

cat sub/dir/A.coffee

class A

cat sub/dir/B.coffee

package sub.dir
  class B

Main file cat test.coffee

import sub/dir/A
import sub/dir/B

package my.namespace

  class C extends A

  class D extends C

caffeine -c test.coffee && cat test.js

// Generated by Caffeine 0.2.7
(function() {
  var __hasProp = {}.hasOwnProperty,
    __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
    sub = {dir: {}},
    my = {namespace: {}},
    __imports = (function() {
      var list;
      list = {};
      this.get = function(key) { return list[key]; };
      list['sub/dir/A'] = (function() {
        var A;
        A = (function() {

          function A() {}

          return A;
        })();
        return A;
      }).call(this);
      list['sub/dir/B'] = (function() {
        var B;
        (function() {
          this.B = B = (function() {

            function B() {}

            return B;
          })();
          return this;
        }).call(sub.dir);
        return B;
      }).call(this);
      return this;
    }).call({}),
    A = __imports.get('sub/dir/A'),
    B = __imports.get('sub/dir/B');

  (function() {
    var C, D;
    this.C = C = (function(_super) {

      __extends(C, _super);

      function C() {
        return C.__super__.constructor.apply(this, arguments);
      }

      return C;
    })(A);
    this.D = D = (function(_super) {

      __extends(D, _super);

      function D() {
        return D.__super__.constructor.apply(this, arguments);
      }

      return D;
    })(C);
    return this;
  }).call(my.namespace);

}).call(this);