haml_coffee_assets 0.8.6 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,5 @@
1
1
  # coding: UTF-8
2
2
 
3
3
  module HamlCoffeeAssets
4
- VERSION = '0.8.6' unless defined?(HamlCoffeeAssets::VERSION)
4
+ VERSION = '0.9.0' unless defined?(HamlCoffeeAssets::VERSION)
5
5
  end
@@ -963,7 +963,7 @@ require.define("/nodes/text.js", function (require, module, exports, __dirname,
963
963
  require.define("/nodes/haml.js", function (require, module, exports, __dirname, __filename) {
964
964
  (function() {
965
965
  var Haml, Node, escapeQuotes,
966
- __hasProp = Object.prototype.hasOwnProperty,
966
+ __hasProp = {}.hasOwnProperty,
967
967
  __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; };
968
968
 
969
969
  Node = require('./node');
@@ -974,8 +974,10 @@ require.define("/nodes/haml.js", function (require, module, exports, __dirname,
974
974
 
975
975
  __extends(Haml, _super);
976
976
 
977
+ Haml.name = 'Haml';
978
+
977
979
  function Haml() {
978
- Haml.__super__.constructor.apply(this, arguments);
980
+ return Haml.__super__.constructor.apply(this, arguments);
979
981
  }
980
982
 
981
983
  Haml.prototype.evaluate = function() {
@@ -1039,16 +1041,18 @@ require.define("/nodes/haml.js", function (require, module, exports, __dirname,
1039
1041
  };
1040
1042
 
1041
1043
  Haml.prototype.parseExpression = function(exp) {
1042
- var attribute, attributes, classes, id, tag, _i, _len, _ref, _ref2;
1044
+ var attribute, attributes, classes, id, tag, _i, _len, _ref, _ref1;
1043
1045
  tag = this.parseTag(exp);
1044
- if (this.preserveTags.indexOf(tag.tag) !== -1) this.preserve = true;
1046
+ if (this.preserveTags.indexOf(tag.tag) !== -1) {
1047
+ this.preserve = true;
1048
+ }
1045
1049
  id = (_ref = tag.ids) != null ? _ref.pop() : void 0;
1046
1050
  classes = tag.classes;
1047
1051
  attributes = [];
1048
1052
  if (tag.attributes) {
1049
- _ref2 = tag.attributes;
1050
- for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
1051
- attribute = _ref2[_i];
1053
+ _ref1 = tag.attributes;
1054
+ for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
1055
+ attribute = _ref1[_i];
1052
1056
  if (attribute.key === 'id') {
1053
1057
  if (id) {
1054
1058
  id += '_' + attribute.value;
@@ -1093,7 +1097,9 @@ require.define("/nodes/haml.js", function (require, module, exports, __dirname,
1093
1097
  assignment = void 0;
1094
1098
  }
1095
1099
  if (whitespace) {
1096
- if (whitespace.indexOf('>') !== -1) this.wsRemoval.around = true;
1100
+ if (whitespace.indexOf('>') !== -1) {
1101
+ this.wsRemoval.around = true;
1102
+ }
1097
1103
  if (whitespace.indexOf('<') !== -1) {
1098
1104
  this.wsRemoval.inside = true;
1099
1105
  this.preserve = true;
@@ -1132,14 +1138,14 @@ require.define("/nodes/haml.js", function (require, module, exports, __dirname,
1132
1138
  };
1133
1139
 
1134
1140
  Haml.prototype.parseAttributes = function(exp) {
1135
- var attributes, bool, datas, findAttributes, key, match, quoted, value, _ref;
1141
+ var attributes, bool, key, quoted, value, _ref;
1136
1142
  attributes = [];
1137
- if (exp === void 0) return attributes;
1138
- _ref = this.getDataAttributes(exp), exp = _ref[0], datas = _ref[1];
1139
- findAttributes = /(?:([-\w]+[\w:-]*\w?|'\w+[\w:-]*\w?'|"\w+[\w:-]*\w?")\s*=\s*("(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|[\w@.]+)|(:\w+[\w:-]*\w?|'[-\w]+[\w:-]*\w?'|"[-\w]+[\w:-]*\w?")\s*=>\s*("(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|[^},]+)|(\w+[\w:-]*\w?|'[-\w]+[\w:-]*\w?'|"[-\w]+[\w:-]*\w?"):\s*("(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|[^},]+))/g;
1140
- while (match = findAttributes.exec(exp)) {
1141
- key = (match[1] || match[3] || match[5]).replace(/^:/, '');
1142
- value = match[2] || match[4] || match[6];
1143
+ if (exp === void 0) {
1144
+ return attributes;
1145
+ }
1146
+ _ref = this.extractAttributes(exp);
1147
+ for (key in _ref) {
1148
+ value = _ref[key];
1143
1149
  bool = false;
1144
1150
  if (['false', ''].indexOf(value) === -1) {
1145
1151
  if (['true'].indexOf(value) !== -1) {
@@ -1160,8 +1166,12 @@ require.define("/nodes/haml.js", function (require, module, exports, __dirname,
1160
1166
  }
1161
1167
  }
1162
1168
  }
1163
- if (quoted = value.match(/^("|')(.*)\1$/)) value = quoted[2];
1164
- if (quoted = key.match(/^("|')(.*)\1$/)) key = quoted[2];
1169
+ if (quoted = value.match(/^("|')(.*)\1$/)) {
1170
+ value = quoted[2];
1171
+ }
1172
+ if (quoted = key.match(/^("|')(.*)\1$/)) {
1173
+ key = quoted[2];
1174
+ }
1165
1175
  attributes.push({
1166
1176
  key: key,
1167
1177
  value: value,
@@ -1169,24 +1179,51 @@ require.define("/nodes/haml.js", function (require, module, exports, __dirname,
1169
1179
  });
1170
1180
  }
1171
1181
  }
1172
- return attributes.concat(datas);
1182
+ return attributes;
1173
1183
  };
1174
1184
 
1175
- Haml.prototype.getDataAttributes = function(exp) {
1176
- var attribute, attributes, data, _i, _len;
1177
- data = /:?data:?\s*(?:=>\s*)?\{([^}]*)\},?/gi.exec(exp);
1178
- if (!(data != null ? data[1] : void 0)) return [exp, []];
1179
- exp = exp.replace(data[0], '');
1180
- attributes = this.parseAttributes(data[1]);
1181
- for (_i = 0, _len = attributes.length; _i < _len; _i++) {
1182
- attribute = attributes[_i];
1183
- attribute.key = "data-" + attribute.key;
1185
+ Haml.prototype.extractAttributes = function(exp) {
1186
+ var attributes, dataAttribute, key, keyValue, keys, pairs, unwrapped, value, _ref, _ref1;
1187
+ attributes = {};
1188
+ unwrapped = exp.substring(1, exp.length - 1).replace(/^\s+|\s+$/g, '');
1189
+ switch (exp.substring(0, 1)) {
1190
+ case '(':
1191
+ keys = /([-\w]+[\w:-]*\w?|'\w+[\w:-]*\w?'|"\w+[\w:-]*\w?")\s*=/g;
1192
+ unwrapped = unwrapped.replace(/\=\s*"([^"]*?)=([^"]*?)"/g, '="$1\u0090=$2"').replace(/\=\s*'([^']*?)=([^']*?)'/g, '=\'$1\u0090=$2\'');
1193
+ break;
1194
+ case '{':
1195
+ if (exp.indexOf('=>') === -1) {
1196
+ keys = /(\w+[\w:-]*\w?|'[-\w]+[\w:-]*\w?'|"[-\w]+[\w:-]*\w?"):/g;
1197
+ unwrapped = unwrapped.replace(/\:\s*"([^"]*?):([^"]*?)"/g, ':"$1\u0090:$2"').replace(/\:\s*'([^']*?):([^']*?)'/g, ':\'$1\u0090=$2\'');
1198
+ } else {
1199
+ keys = /:?(\w+[\w:-]*\w?|'[-\w]+[\w:-]*\w?'|"[-\w]+[\w:-]*\w?")\s*=>/g;
1200
+ unwrapped = unwrapped.replace(/\=>\s*"([^"]*?)=>([^"]*?)"/g, '=>"$1\u0090:$2"').replace(/\=>\s*'([^']*?)=>([^']*?)'/g, '=>\'$1\u0090=>$2\'');
1201
+ }
1184
1202
  }
1185
- return [exp, attributes];
1203
+ pairs = unwrapped.split(keys).filter(Boolean);
1204
+ dataAttribute = false;
1205
+ while (pairs.length) {
1206
+ keyValue = pairs.splice(0, 2);
1207
+ key = (_ref = keyValue[0]) != null ? _ref.replace(/^\s+|\s+$/g, '').replace(/^:/, '') : void 0;
1208
+ value = (_ref1 = keyValue[1]) != null ? _ref1.replace(/^\s+|\s+$/g, '').replace(/,$/, '').replace(/\u0090/, '') : void 0;
1209
+ if (key === 'data') {
1210
+ dataAttribute = true;
1211
+ } else if (key && value) {
1212
+ if (dataAttribute) {
1213
+ key = "data-" + key;
1214
+ if (/}$/.test(value)) {
1215
+ value = value.substring(0, value.length - 1).replace(/^\s+|\s+$/g, '');
1216
+ dataAttribute = false;
1217
+ }
1218
+ }
1219
+ attributes[key] = value;
1220
+ }
1221
+ }
1222
+ return attributes;
1186
1223
  };
1187
1224
 
1188
1225
  Haml.prototype.buildHtmlTagPrefix = function(tokens) {
1189
- var attribute, classes, interpolation, klass, tagParts, _i, _j, _len, _len2, _ref, _ref2;
1226
+ var attribute, classes, interpolation, klass, tagParts, _i, _j, _len, _len1, _ref, _ref1;
1190
1227
  tagParts = ["<" + tokens.tag];
1191
1228
  if (tokens.classes) {
1192
1229
  classes = tokens.classes.sort().join(' ');
@@ -1207,11 +1244,13 @@ require.define("/nodes/haml.js", function (require, module, exports, __dirname,
1207
1244
  }
1208
1245
  tagParts.push("class='" + classes + "'");
1209
1246
  }
1210
- if (tokens.id) tagParts.push("id='" + tokens.id + "'");
1247
+ if (tokens.id) {
1248
+ tagParts.push("id='" + tokens.id + "'");
1249
+ }
1211
1250
  if (tokens.attributes) {
1212
- _ref2 = tokens.attributes;
1213
- for (_j = 0, _len2 = _ref2.length; _j < _len2; _j++) {
1214
- attribute = _ref2[_j];
1251
+ _ref1 = tokens.attributes;
1252
+ for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
1253
+ attribute = _ref1[_j];
1215
1254
  if (attribute.bool && this.format === 'html5') {
1216
1255
  tagParts.push("" + attribute.key);
1217
1256
  } else {
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: haml_coffee_assets
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.6
4
+ version: 0.9.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-04-30 00:00:00.000000000Z
12
+ date: 2012-05-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: execjs
@@ -219,6 +219,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
219
219
  - - ! '>='
220
220
  - !ruby/object:Gem::Version
221
221
  version: '0'
222
+ segments:
223
+ - 0
224
+ hash: -1713191990820436821
222
225
  required_rubygems_version: !ruby/object:Gem::Requirement
223
226
  none: false
224
227
  requirements:
@@ -227,7 +230,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
227
230
  version: 1.3.6
228
231
  requirements: []
229
232
  rubyforge_project: haml_coffee_assets
230
- rubygems_version: 1.8.19
233
+ rubygems_version: 1.8.24
231
234
  signing_key:
232
235
  specification_version: 3
233
236
  summary: Haml CoffeeScript templates