jade-rails 1.9.1.0 → 1.9.2.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1efd81616df034adfbadab46e346124e47159786
4
- data.tar.gz: acce583b683b4289a1bb60f0f61e2ada7c6e0f9c
3
+ metadata.gz: 696efa36a4f79013cd5a7f3ad58e06fafc8d3030
4
+ data.tar.gz: 123431b4eefafe0970a39518040a132df4ce9a91
5
5
  SHA512:
6
- metadata.gz: 387672ce7b135d2612f01b869fcc751a0472546054313140316112b4d6eab7e090e99e8b23f33584357741bec04faa668ff2025285fb3935910b7fcfdb8b217a
7
- data.tar.gz: 4ae350b05f81d48925a0a40c359a44e94fa85a957f1da1cac83513d62a39143048b1f62ede13bde841da82e6dde517b89c54a1bd36cae0a77f6ce374e0c8afb3
6
+ metadata.gz: b3bce3121c8d27d34a90a5a5b2f51d3c3c82df5a0dbb0362491c862cf8bf7b01fdc6d63d8b058974ba7ba5b2eeade611297029ed1b643a57c1129608e98f8f80
7
+ data.tar.gz: 7cc4e08918c0b70cbec3cfc1be01fe23c409c6075dbfd825deb2e680209784db544f35b3cd34a8fbe6a53d4c3a95e728c4e396a695e1d259f6c410570fb23860
data/README.md CHANGED
@@ -11,7 +11,7 @@ to render Jade templates anywhere on the front end of your Rails app.
11
11
  Add to your Gemfile:
12
12
 
13
13
  ```ruby
14
- gem 'jade-rails', '~> 1.9.1.0'
14
+ gem 'jade-rails', '~> 1.9.2.0'
15
15
  ```
16
16
 
17
17
  In your `application.js`, require the Jade runtime before any files that include
@@ -1,3 +1,3 @@
1
1
  module Jade
2
- VERSION = '1.9.1.0'
2
+ VERSION = '1.9.2.0'
3
3
  end
@@ -344,7 +344,7 @@ Compiler.prototype = {
344
344
  var args = mixin.args || '';
345
345
  var block = mixin.block;
346
346
  var attrs = mixin.attrs;
347
- var attrsBlocks = mixin.attributeBlocks;
347
+ var attrsBlocks = mixin.attributeBlocks.slice();
348
348
  var pp = this.pp;
349
349
  var dynamic = mixin.name[0]==='#';
350
350
  var key = mixin.name;
@@ -454,10 +454,10 @@ Compiler.prototype = {
454
454
  if (pp && !tag.isInline())
455
455
  this.prettyIndent(0, true);
456
456
 
457
- if (tag.selfClosing || (!this.xml && selfClosing.indexOf(tag.name) !== -1)) {
457
+ if (tag.selfClosing || (!this.xml && selfClosing[tag.name])) {
458
458
  this.buffer('<');
459
459
  bufferName();
460
- this.visitAttributes(tag.attrs, tag.attributeBlocks);
460
+ this.visitAttributes(tag.attrs, tag.attributeBlocks.slice());
461
461
  this.terse
462
462
  ? this.buffer('>')
463
463
  : this.buffer('/>');
@@ -473,7 +473,7 @@ Compiler.prototype = {
473
473
  // Optimize attributes buffering
474
474
  this.buffer('<');
475
475
  bufferName();
476
- this.visitAttributes(tag.attrs, tag.attributeBlocks);
476
+ this.visitAttributes(tag.attrs, tag.attributeBlocks.slice());
477
477
  this.buffer('>');
478
478
  if (tag.code) this.visitCode(tag.code);
479
479
  this.visit(tag.block);
@@ -771,7 +771,9 @@ var Parser = require('./parser')
771
771
  * Expose self closing tags.
772
772
  */
773
773
 
774
- exports.selfClosing = require('void-elements');
774
+ // FIXME: either stop exporting selfClosing in v2 or export the new object
775
+ // form
776
+ exports.selfClosing = Object.keys(require('void-elements'));
775
777
 
776
778
  /**
777
779
  * Default supported doctypes.
@@ -988,34 +990,52 @@ exports.compile = function(str, options){
988
990
  *
989
991
  * @param {String} str
990
992
  * @param {Options} options
991
- * @return {String}
993
+ * @return {Object}
992
994
  * @api public
993
995
  */
994
996
 
995
- exports.compileClient = function(str, options){
997
+ exports.compileClientWithDependenciesTracked = function(str, options){
996
998
  var options = options || {};
997
999
  var name = options.name || 'template';
998
1000
  var filename = options.filename ? utils.stringify(options.filename) : 'undefined';
999
1001
  var fn;
1000
1002
 
1001
1003
  str = String(str);
1002
-
1004
+ options.compileDebug = options.compileDebug ? true : false;
1005
+ var parsed = parse(str, options);
1003
1006
  if (options.compileDebug) {
1004
- options.compileDebug = true;
1005
1007
  fn = [
1006
1008
  'var jade_debug = [{ lineno: 1, filename: ' + filename + ' }];'
1007
1009
  , 'try {'
1008
- , parse(str, options).body
1010
+ , parsed.body
1009
1011
  , '} catch (err) {'
1010
1012
  , ' jade.rethrow(err, jade_debug[0].filename, jade_debug[0].lineno, ' + utils.stringify(str) + ');'
1011
1013
  , '}'
1012
1014
  ].join('\n');
1013
1015
  } else {
1014
- options.compileDebug = false;
1015
- fn = parse(str, options).body;
1016
+ fn = parsed.body;
1016
1017
  }
1017
1018
 
1018
- return 'function ' + name + '(locals) {\n' + fn + '\n}';
1019
+ return {body: 'function ' + name + '(locals) {\n' + fn + '\n}', dependencies: parsed.dependencies};
1020
+ };
1021
+
1022
+ /**
1023
+ * Compile a JavaScript source representation of the given jade `str`.
1024
+ *
1025
+ * Options:
1026
+ *
1027
+ * - `compileDebug` When it is `true`, the source code is included in
1028
+ * the compiled template for better error messages.
1029
+ * - `filename` used to improve errors when `compileDebug` is not `true` and to resolve imports/extends
1030
+ * - `name` the name of the resulting function (defaults to "template")
1031
+ *
1032
+ * @param {String} str
1033
+ * @param {Options} options
1034
+ * @return {String}
1035
+ * @api public
1036
+ */
1037
+ exports.compileClient = function (str, options) {
1038
+ return exports.compileClientWithDependenciesTracked(str, options).body;
1019
1039
  };
1020
1040
 
1021
1041
  /**
@@ -1366,12 +1386,7 @@ Lexer.prototype = {
1366
1386
 
1367
1387
  interpolation: function() {
1368
1388
  if (/^#\{/.test(this.input)) {
1369
- var match;
1370
- try {
1371
- match = this.bracketExpression(1);
1372
- } catch (ex) {
1373
- return;//not an interpolation expression, just an unmatched open interpolation
1374
- }
1389
+ var match = this.bracketExpression(1);
1375
1390
 
1376
1391
  this.consume(match.end + 1);
1377
1392
  return this.tok('interpolation', match.src);
@@ -1391,6 +1406,10 @@ Lexer.prototype = {
1391
1406
  name = name.slice(0, -1);
1392
1407
  tok = this.tok('tag', name);
1393
1408
  this.defer(this.tok(':'));
1409
+ if (this.input[0] !== ' ') {
1410
+ console.warn('Warning: space required after `:` on line ' + this.lineno +
1411
+ ' of jade file "' + this.filename + '"');
1412
+ }
1394
1413
  while (' ' == this.input[0]) this.input = this.input.substr(1);
1395
1414
  } else {
1396
1415
  tok = this.tok('tag', name);
@@ -1624,12 +1643,7 @@ Lexer.prototype = {
1624
1643
  tok = this.tok('call', captures[3]);
1625
1644
  } else {
1626
1645
  // interpolated call
1627
- var match;
1628
- try {
1629
- match = this.bracketExpression(2 + captures[1].length);
1630
- } catch (ex) {
1631
- return;//not an interpolation expression, just an unmatched open interpolation
1632
- }
1646
+ var match = this.bracketExpression(2 + captures[1].length);
1633
1647
  this.consume(match.end + 1);
1634
1648
  assertExpression(match.src);
1635
1649
  tok = this.tok('call', '#{'+match.src+'}');
@@ -1637,14 +1651,10 @@ Lexer.prototype = {
1637
1651
 
1638
1652
  // Check for args (not attributes)
1639
1653
  if (captures = /^ *\(/.exec(this.input)) {
1640
- try {
1641
- var range = this.bracketExpression(captures[0].length - 1);
1642
- if (!/^\s*[-\w]+ *=/.test(range.src)) { // not attributes
1643
- this.consume(range.end + 1);
1644
- tok.args = range.src;
1645
- }
1646
- } catch (ex) {
1647
- //not a bracket expcetion, just unmatched open parens
1654
+ var range = this.bracketExpression(captures[0].length - 1);
1655
+ if (!/^\s*[-\w]+ *=/.test(range.src)) { // not attributes
1656
+ this.consume(range.end + 1);
1657
+ tok.args = range.src;
1648
1658
  }
1649
1659
  if (tok.args) {
1650
1660
  assertExpression('[' + tok.args + ']');
@@ -2036,7 +2046,13 @@ Lexer.prototype = {
2036
2046
  */
2037
2047
 
2038
2048
  colon: function() {
2039
- return this.scan(/^: */, ':');
2049
+ var good = /^: +/.test(this.input);
2050
+ var res = this.scan(/^: */, ':');
2051
+ if (res && !good) {
2052
+ console.warn('Warning: space required after `:` on line ' + this.lineno +
2053
+ ' of jade file "' + this.filename + '"');
2054
+ }
2055
+ return res;
2040
2056
  },
2041
2057
 
2042
2058
  fail: function () {
@@ -2753,7 +2769,7 @@ var Parser = exports = module.exports = function Parser(str, filename, options){
2753
2769
  this.mixins = {};
2754
2770
  this.options = options;
2755
2771
  this.contexts = [this];
2756
- this.inMixin = false;
2772
+ this.inMixin = 0;
2757
2773
  this.dependencies = [];
2758
2774
  this.inBlock = 0;
2759
2775
  };
@@ -3023,6 +3039,7 @@ Parser.prototype = {
3023
3039
  this.expect('indent');
3024
3040
  while ('outdent' != this.peek().type) {
3025
3041
  switch (this.peek().type) {
3042
+ case 'comment':
3026
3043
  case 'newline':
3027
3044
  this.advance();
3028
3045
  break;
@@ -3359,10 +3376,10 @@ Parser.prototype = {
3359
3376
 
3360
3377
  // definition
3361
3378
  if ('indent' == this.peek().type) {
3362
- this.inMixin = true;
3379
+ this.inMixin++;
3363
3380
  mixin = new nodes.Mixin(name, args, this.block(), false);
3364
3381
  this.mixins[name] = mixin;
3365
- this.inMixin = false;
3382
+ this.inMixin--;
3366
3383
  return mixin;
3367
3384
  // call
3368
3385
  } else {
@@ -7449,28 +7466,28 @@ function findGlobals(source) {
7449
7466
 
7450
7467
  },{}],34:[function(require,module,exports){
7451
7468
  /**
7452
- * This file automatically generated from `build.js`.
7469
+ * This file automatically generated from `pre-publish.js`.
7453
7470
  * Do not manually edit.
7454
7471
  */
7455
7472
 
7456
- module.exports = [
7457
- "area",
7458
- "base",
7459
- "br",
7460
- "col",
7461
- "embed",
7462
- "hr",
7463
- "img",
7464
- "input",
7465
- "keygen",
7466
- "link",
7467
- "menuitem",
7468
- "meta",
7469
- "param",
7470
- "source",
7471
- "track",
7472
- "wbr"
7473
- ];
7473
+ module.exports = {
7474
+ "area": true,
7475
+ "base": true,
7476
+ "br": true,
7477
+ "col": true,
7478
+ "embed": true,
7479
+ "hr": true,
7480
+ "img": true,
7481
+ "input": true,
7482
+ "keygen": true,
7483
+ "link": true,
7484
+ "menuitem": true,
7485
+ "meta": true,
7486
+ "param": true,
7487
+ "source": true,
7488
+ "track": true,
7489
+ "wbr": true
7490
+ };
7474
7491
 
7475
7492
  },{}],35:[function(require,module,exports){
7476
7493
  'use strict';
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jade-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.9.1.0
4
+ version: 1.9.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paul Raythattha
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-23 00:00:00.000000000 Z
11
+ date: 2015-02-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: execjs