coffee-react 0.5.2 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +6 -0
  3. data/coffee-react-transform.js +31 -5
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 00b7c42111d6f81823d512fd578872d2e54ab820
4
- data.tar.gz: e0c4d764ff9387b0325c65a5c3a7665ce073bee3
3
+ metadata.gz: 905445600e62aa5f3f97b4fa02cd3dfcc696bb1c
4
+ data.tar.gz: 23fc1d6b939116ec60179ab944558b5b966f25c4
5
5
  SHA512:
6
- metadata.gz: 9b921c56d7de82b30933abb8b1e2d52c6d8a6c2a18e85552d815b0b08517245be970066a199421cdd8d67bf85e9e4ca30f76333896bfd4e2752db5f4566c09d0
7
- data.tar.gz: 1b65034629b758a8ed88b188ecce17d7762983687a9158eec04653400cf2a705c58ab7427222c30457258890881de88118919196eca2299e378203c833cf2966
6
+ metadata.gz: a8ec8f1ce4fb69ecdfb2e0096ac197aaff74c6385ab3f23b7797eec46a9d56576e3b8f1d0e6755a4b4828b593944ef56e7e849ca4eae67f23ffddf08f3f64f4c
7
+ data.tar.gz: 87a81568450586805342892db37537b9d86f5b7074068349f425cf27b5612d81da0570594b329fcae1a0af2332997b4447a94c212d05982a8b27f6164687c2c9
data/README.md CHANGED
@@ -11,6 +11,12 @@ Installation
11
11
 
12
12
  gem install coffee-react
13
13
 
14
+
15
+ Compatibility
16
+ ------------
17
+ ruby-coffee-react 2.x is compatible with react ^0.12.0
18
+ ruby-coffee-react 0.x is compatible with react <=0.11.2
19
+
14
20
  Dependencies
15
21
  ------------
16
22
 
@@ -1030,7 +1030,7 @@ HEREGEX = /^\/{3}((?:\\?[\s\S])+?)\/{3}([imgy]{0,4})(?!\w)/;
1030
1030
 
1031
1031
  },{"./helpers":3,"./symbols":8}],6:[function(_dereq_,module,exports){
1032
1032
  // Generated by CoffeeScript 1.7.1
1033
- var $, HTML_ELEMENTS, SPACES_ONLY, Serialiser, TEXT_LEADING_WHITESPACE, TEXT_TRAILING_WHITESPACE, WHITESPACE_ONLY, containsNewlines, entityDecode, exports, find, firstNonWhitespaceChild, genericBranchSerialiser, genericLeafSerialiser, last, nodeSerialisers, serialise, stringEscape, _ref;
1033
+ var $, HTML_ELEMENTS, SPACES_ONLY, Serialiser, TEXT_LEADING_WHITESPACE, TEXT_TRAILING_WHITESPACE, WHITESPACE_ONLY, containsNewlines, entityDecode, exports, find, firstNonWhitespaceChild, genericBranchSerialiser, genericLeafSerialiser, joinList, last, nodeSerialisers, serialise, stringEscape, _ref;
1034
1034
 
1035
1035
  _ref = _dereq_('./helpers'), last = _ref.last, find = _ref.find;
1036
1036
 
@@ -1050,11 +1050,18 @@ Serialiser = (function() {
1050
1050
  function Serialiser() {}
1051
1051
 
1052
1052
  Serialiser.prototype.serialise = function(parseTree) {
1053
+ var domObjectParts;
1053
1054
  if (parseTree.children && parseTree.children.length && parseTree.children[0].type === $.CJSX_PRAGMA) {
1054
1055
  this.domObject = parseTree.children[0].value;
1055
1056
  } else {
1056
1057
  this.domObject = 'React.DOM';
1057
1058
  }
1059
+ domObjectParts = this.domObject.split('.');
1060
+ if (domObjectParts.length > 0 && domObjectParts[0] !== '') {
1061
+ this.reactObject = domObjectParts[0];
1062
+ } else {
1063
+ this.reactObject = 'React';
1064
+ }
1058
1065
  return this.serialiseNode(parseTree);
1059
1066
  };
1060
1067
 
@@ -1099,7 +1106,7 @@ Serialiser = (function() {
1099
1106
  }
1100
1107
  flushPairs();
1101
1108
  }
1102
- return "Object.assign(" + (assigns.join(', ')) + ")";
1109
+ return "Object.assign(" + (joinList(assigns)) + ")";
1103
1110
  };
1104
1111
 
1105
1112
  Serialiser.prototype.serialiseAttributePairs = function(children) {
@@ -1169,7 +1176,7 @@ nodeSerialisers = {
1169
1176
  return null;
1170
1177
  },
1171
1178
  CJSX_EL: function(node) {
1172
- var accumulatedWhitespace, child, prefix, serialisedChild, serialisedChildren, _i, _len, _ref1;
1179
+ var accumulatedWhitespace, child, element, serialisedChild, serialisedChildren, _i, _len, _ref1;
1173
1180
  serialisedChildren = [];
1174
1181
  accumulatedWhitespace = '';
1175
1182
  _ref1 = node.children;
@@ -1189,8 +1196,12 @@ nodeSerialisers = {
1189
1196
  serialisedChildren[serialisedChildren.length - 1] += accumulatedWhitespace;
1190
1197
  accumulatedWhitespace = '';
1191
1198
  }
1192
- prefix = HTML_ELEMENTS[node.value] != null ? this.domObject + '.' : '';
1193
- return prefix + node.value + '(' + serialisedChildren.join(', ') + ')';
1199
+ if (HTML_ELEMENTS[node.value] != null) {
1200
+ element = '"' + node.value + '"';
1201
+ } else {
1202
+ element = node.value;
1203
+ }
1204
+ return "" + this.reactObject + ".createElement(" + element + ", " + (joinList(serialisedChildren)) + ")";
1194
1205
  },
1195
1206
  CJSX_ESC: function(node) {
1196
1207
  var childrenSerialised;
@@ -1275,6 +1286,21 @@ containsNewlines = function(text) {
1275
1286
  return text.indexOf('\n') > -1;
1276
1287
  };
1277
1288
 
1289
+ joinList = function(items) {
1290
+ var i, output;
1291
+ output = items[items.length - 1];
1292
+ i = items.length - 2;
1293
+ while (i >= 0) {
1294
+ if (output.charAt(0) === '\n') {
1295
+ output = items[i] + ',' + output;
1296
+ } else {
1297
+ output = items[i] + ', ' + output;
1298
+ }
1299
+ i--;
1300
+ }
1301
+ return output;
1302
+ };
1303
+
1278
1304
  SPACES_ONLY = /^\s+$/;
1279
1305
 
1280
1306
  WHITESPACE_ONLY = /^[\n\s]+$/;
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: coffee-react
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.2
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Friend
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-09 00:00:00.000000000 Z
11
+ date: 2014-10-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: execjs