haml_coffee_assets 1.4.3 → 1.4.5

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 = '1.4.3' unless defined?(HamlCoffeeAssets::VERSION)
4
+ VERSION = '1.4.5' unless defined?(HamlCoffeeAssets::VERSION)
5
5
  end
data/lib/js/hamlcoffee.js CHANGED
@@ -363,7 +363,7 @@ require.define("/haml-coffee.coffee", function (require, module, exports, __dirn
363
363
 
364
364
  module.exports = HamlCoffee = (function() {
365
365
 
366
- HamlCoffee.VERSION = '1.4.2';
366
+ HamlCoffee.VERSION = '1.4.5';
367
367
 
368
368
  function HamlCoffee(options) {
369
369
  var _base, _base2, _base3, _base4, _base5, _base6, _base7, _base8, _base9, _ref, _ref2, _ref3, _ref4, _ref5, _ref6, _ref7, _ref8, _ref9;
@@ -723,10 +723,14 @@ require.define("/haml-coffee.coffee", function (require, module, exports, __dirn
723
723
  };
724
724
 
725
725
  HamlCoffee.prototype.convertBooleans = function(code) {
726
- if (this.options.format === 'xhtml') {
727
- return '.replace(/\\s(\\w+)=\'\u0093true\'/mg, " $1=\'$1\'").replace(/\\s(\\w+)=\'\u0093false\'/mg, \'\')';
726
+ if (code.indexOf('$c') !== -1) {
727
+ if (this.options.format === 'xhtml') {
728
+ return '.replace(/\\s(\\w+)=\'\u0093true\'/mg, " $1=\'$1\'").replace(/\\s(\\w+)=\'\u0093false\'/mg, \'\')';
729
+ } else {
730
+ return '.replace(/\\s(\\w+)=\'\u0093true\'/mg, \' $1\').replace(/\\s(\\w+)=\'\u0093false\'/mg, \'\')';
731
+ }
728
732
  } else {
729
- return '.replace(/\\s(\\w+)=\'\u0093true\'/mg, \' $1\').replace(/\\s(\\w+)=\'\u0093false\'/mg, \'\')';
733
+ return '';
730
734
  }
731
735
  };
732
736
 
@@ -1074,7 +1078,7 @@ require.define("/nodes/haml.coffee", function (require, module, exports, __dirna
1074
1078
  var attributes, classes, id, key, tag, value, _ref, _ref2;
1075
1079
  tag = this.parseTag(exp);
1076
1080
  if (this.preserveTags.indexOf(tag.tag) !== -1) this.preserve = true;
1077
- id = this.wrapCode((_ref = tag.ids) != null ? _ref.pop() : void 0, true);
1081
+ id = this.interpolateCodeAttribute((_ref = tag.ids) != null ? _ref.pop() : void 0, true);
1078
1082
  classes = tag.classes;
1079
1083
  attributes = {};
1080
1084
  if (tag.attributes) {
@@ -1083,9 +1087,9 @@ require.define("/nodes/haml.coffee", function (require, module, exports, __dirna
1083
1087
  value = _ref2[key];
1084
1088
  if (key === 'id') {
1085
1089
  if (id) {
1086
- id += '_' + this.wrapCode(value, true);
1090
+ id += '_' + this.interpolateCodeAttribute(value, true);
1087
1091
  } else {
1088
- id = this.wrapCode(value, true);
1092
+ id = this.interpolateCodeAttribute(value, true);
1089
1093
  }
1090
1094
  } else if (key === 'class') {
1091
1095
  classes || (classes = []);
@@ -1281,7 +1285,7 @@ require.define("/nodes/haml.coffee", function (require, module, exports, __dirna
1281
1285
  _results = [];
1282
1286
  for (_i = 0, _len = _ref.length; _i < _len; _i++) {
1283
1287
  name = _ref[_i];
1284
- name = this.wrapCode(name, true);
1288
+ name = this.interpolateCodeAttribute(name, true);
1285
1289
  if (name.indexOf('#{') !== -1) hasDynamicClass = true;
1286
1290
  _results.push(name);
1287
1291
  }
@@ -1313,14 +1317,14 @@ require.define("/nodes/haml.coffee", function (require, module, exports, __dirna
1313
1317
  }
1314
1318
  }
1315
1319
  } else {
1316
- tagParts.push("" + key + "=" + (this.quoteAndEscapeAttributeValue(this.wrapCode(value))));
1320
+ tagParts.push("" + key + "=" + (this.quoteAndEscapeAttributeValue(this.interpolateCodeAttribute(value))));
1317
1321
  }
1318
1322
  }
1319
1323
  }
1320
1324
  return tagParts.join(' ');
1321
1325
  };
1322
1326
 
1323
- Haml.prototype.wrapCode = function(text, unwrap) {
1327
+ Haml.prototype.interpolateCodeAttribute = function(text, unwrap) {
1324
1328
  var quoted;
1325
1329
  if (unwrap == null) unwrap = false;
1326
1330
  if (!text) return;
@@ -1344,7 +1348,7 @@ require.define("/nodes/haml.coffee", function (require, module, exports, __dirna
1344
1348
  };
1345
1349
 
1346
1350
  Haml.prototype.quoteAndEscapeAttributeValue = function(value, code) {
1347
- var escaped, hasDoubleQuotes, hasInterpolation, hasSingleQuotes, quoted, result, token, tokens, _i, _len;
1351
+ var escaped, hasDoubleQuotes, hasInterpolation, hasSingleQuotes, quoted, result, token, tokens;
1348
1352
  if (code == null) code = false;
1349
1353
  if (!value) return;
1350
1354
  if (quoted = value.match(/^("|')(.*)\1$/)) value = quoted[2];
@@ -1352,15 +1356,32 @@ require.define("/nodes/haml.coffee", function (require, module, exports, __dirna
1352
1356
  hasSingleQuotes = false;
1353
1357
  hasDoubleQuotes = false;
1354
1358
  hasInterpolation = false;
1355
- for (_i = 0, _len = tokens.length; _i < _len; _i++) {
1356
- token = tokens[_i];
1357
- if (token.slice(0, 2) === '#{') {
1358
- hasInterpolation = true;
1359
- } else {
1360
- if (!hasSingleQuotes) hasSingleQuotes = token.indexOf("'") !== -1;
1361
- if (!hasDoubleQuotes) hasDoubleQuotes = token.indexOf('"') !== -1;
1359
+ tokens = (function() {
1360
+ var _i, _len, _results;
1361
+ _results = [];
1362
+ for (_i = 0, _len = tokens.length; _i < _len; _i++) {
1363
+ token = tokens[_i];
1364
+ if (token.slice(0, 2) === '#{') {
1365
+ if (token.indexOf('$e') === -1 && token.indexOf('$c') === -1) {
1366
+ if (this.escapeAttributes) {
1367
+ if (this.cleanValue) {
1368
+ token = '#{ $e($c(' + token.slice(2, -1) + ')) }';
1369
+ } else {
1370
+ token = '#{ $e(' + token.slice(2, -1) + ') }';
1371
+ }
1372
+ } else {
1373
+ if (this.cleanValue) token = '#{ $c(' + token.slice(2, -1) + ') }';
1374
+ }
1375
+ }
1376
+ hasInterpolation = true;
1377
+ } else {
1378
+ if (!hasSingleQuotes) hasSingleQuotes = token.indexOf("'") !== -1;
1379
+ if (!hasDoubleQuotes) hasDoubleQuotes = token.indexOf('"') !== -1;
1380
+ }
1381
+ _results.push(token);
1362
1382
  }
1363
- }
1383
+ return _results;
1384
+ }).call(this);
1364
1385
  if (code) {
1365
1386
  if (hasInterpolation) {
1366
1387
  result = "\"" + (tokens.join('')) + "\"";
@@ -1376,10 +1397,10 @@ require.define("/nodes/haml.coffee", function (require, module, exports, __dirna
1376
1397
  }
1377
1398
  if (hasDoubleQuotes && !hasSingleQuotes) {
1378
1399
  escaped = (function() {
1379
- var _j, _len2, _results;
1400
+ var _i, _len, _results;
1380
1401
  _results = [];
1381
- for (_j = 0, _len2 = tokens.length; _j < _len2; _j++) {
1382
- token = tokens[_j];
1402
+ for (_i = 0, _len = tokens.length; _i < _len; _i++) {
1403
+ token = tokens[_i];
1383
1404
  _results.push(escapeQuotes(token));
1384
1405
  }
1385
1406
  return _results;
@@ -1388,10 +1409,10 @@ require.define("/nodes/haml.coffee", function (require, module, exports, __dirna
1388
1409
  }
1389
1410
  if (hasSingleQuotes && hasDoubleQuotes) {
1390
1411
  escaped = (function() {
1391
- var _j, _len2, _results;
1412
+ var _i, _len, _results;
1392
1413
  _results = [];
1393
- for (_j = 0, _len2 = tokens.length; _j < _len2; _j++) {
1394
- token = tokens[_j];
1414
+ for (_i = 0, _len = tokens.length; _i < _len; _i++) {
1415
+ token = tokens[_i];
1395
1416
  _results.push(escapeQuotes(token).replace(/'/g, '&#39;'));
1396
1417
  }
1397
1418
  return _results;
@@ -1691,3 +1712,73 @@ require.define("/nodes/filter.coffee", function (require, module, exports, __dir
1691
1712
  }).call(this);
1692
1713
 
1693
1714
  });
1715
+
1716
+ require.define("/hamlc.coffee", function (require, module, exports, __dirname, __filename) {
1717
+ (function() {
1718
+ var CoffeeScript, Compiler, fs, __expressCache;
1719
+
1720
+ fs = require('fs');
1721
+
1722
+ Compiler = require('./haml-coffee');
1723
+
1724
+ if (process.title === 'node') {
1725
+ CoffeeScript = require('coffee-script');
1726
+ } else {
1727
+ CoffeeScript = window.CoffeeScript;
1728
+ }
1729
+
1730
+ __expressCache = {};
1731
+
1732
+ module.exports = {
1733
+ compile: function(source, options) {
1734
+ var compiler, template;
1735
+ if (options == null) options = {};
1736
+ compiler = new Compiler(options);
1737
+ compiler.parse(source);
1738
+ template = new Function(CoffeeScript.compile(compiler.precompile(), {
1739
+ bare: true
1740
+ }));
1741
+ return function(params) {
1742
+ return template.call(params);
1743
+ };
1744
+ },
1745
+ template: function(source, name, namespace, options) {
1746
+ var compiler;
1747
+ if (options == null) options = {};
1748
+ compiler = new Compiler(options);
1749
+ compiler.parse(source);
1750
+ return CoffeeScript.compile(compiler.render(name, namespace));
1751
+ },
1752
+ __express: function(filename, options, callback) {
1753
+ var source;
1754
+ if (!!(options && options.constructor && options.call && options.apply)) {
1755
+ callback = options;
1756
+ options = {};
1757
+ }
1758
+ try {
1759
+ if (options.cache && __expressCache[filename]) {
1760
+ return callback(null, __expressCache[filename](options));
1761
+ } else {
1762
+ options.filename = filename;
1763
+ source = fs.readFileSync(filename, 'utf8');
1764
+ if (options.cache) {
1765
+ __expressCache[filename] = module.exports.compile(source, options);
1766
+ return callback(null, __expressCache[filename](options));
1767
+ } else {
1768
+ return callback(null, module.exports.compile(source, options)(options));
1769
+ }
1770
+ }
1771
+ } catch (err) {
1772
+ return callback(err);
1773
+ }
1774
+ }
1775
+ };
1776
+
1777
+ }).call(this);
1778
+
1779
+ });
1780
+
1781
+ require.define("fs", function (require, module, exports, __dirname, __filename) {
1782
+ // nothing to see here... no file methods for the browser
1783
+
1784
+ });
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: 1.4.3
4
+ version: 1.4.5
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-08-20 00:00:00.000000000 Z
12
+ date: 2012-08-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: coffee-script
@@ -108,7 +108,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
108
108
  version: '0'
109
109
  segments:
110
110
  - 0
111
- hash: 2912896111803617098
111
+ hash: 4005685903116156639
112
112
  required_rubygems_version: !ruby/object:Gem::Requirement
113
113
  none: false
114
114
  requirements: