mustache-js-rails 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of mustache-js-rails might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ec03f20009a55fa272176d860600a1997d63179d
4
- data.tar.gz: a2fbb16f78441d8f7d9dc98b566f188ea49fd323
3
+ metadata.gz: d658a53c1a9063220c7daf0d0a9ba752fec30531
4
+ data.tar.gz: ce7b2dd677355aad2e6a45deaf819cbaad132ac1
5
5
  SHA512:
6
- metadata.gz: 19cba5011910d02945c70831d1061b562cb8c3a4ea3f0e040fc3fd24e234a4991031a9db9b5a672bbccf74a96b900af91749185c1f0aa677a5a238995d627d81
7
- data.tar.gz: 544bd5d540284a4a7eba1336f4d4749031bacb425bd04017318ac374996e6fb96a1d25b5ead5538b8d6881f73c03d6d3661f700ed22e6ee36a9fb57ca7dbab76
6
+ metadata.gz: cf540b78ab2ace41dd12eeda6cfc3cc7fcf3420b29ec0557034900f749e70f215670c0a4ef5d69ee63dcb214c98085829367e0c575f6630c5784d4422a6883ea
7
+ data.tar.gz: da57b314657f3bbff435ff8c73ce25d6d575600085ad44dbe4912502a9e42d4d8bc55d1e95f552449a436e12cb92112b51fdec635164ea7e2f5281a322dec72e
data/README.md CHANGED
@@ -5,7 +5,7 @@ and [mustache jQuery integration](https://github.com/jonnyreeves/jquery-Mustache
5
5
 
6
6
  Integrated versions are:
7
7
 
8
- * mustache.js - <b id="mustache-js-version">1.0.0</b>
8
+ * mustache.js - <b id="mustache-js-version">1.1.0</b>
9
9
  * jQuery mustache - <b id="jquery-mustache-js-version">0.2.8</b>
10
10
 
11
11
  ### Installation
data/Rakefile CHANGED
@@ -3,6 +3,8 @@ require 'bundler/setup'
3
3
  require 'bundler/gem_tasks'
4
4
 
5
5
  task :update do
6
+ Dir['*.gem'].each{ |f| FileUtils.rm(f) }
7
+
6
8
  js_dir = 'vendor/assets/javascripts'
7
9
  css_dir = 'vendor/assets/stylesheets'
8
10
  img_dir = 'vendor/assets/images'
@@ -39,4 +41,4 @@ task :build do
39
41
  else
40
42
  raise "Gem was not built!"
41
43
  end
42
- end
44
+ end
@@ -1,3 +1,3 @@
1
1
  module MustacheJsRails
2
- VERSION = "1.0.0"
2
+ VERSION = "1.1.0"
3
3
  end
@@ -444,88 +444,95 @@
444
444
  Writer.prototype.renderTokens = function (tokens, context, partials, originalTemplate) {
445
445
  var buffer = '';
446
446
 
447
- // This function is used to render an arbitrary template
448
- // in the current context by higher-order sections.
449
- var self = this;
450
- function subRender(template) {
451
- return self.render(template, context, partials);
452
- }
453
-
454
- var token, value;
447
+ var token, symbol, value;
455
448
  for (var i = 0, numTokens = tokens.length; i < numTokens; ++i) {
449
+ value = undefined;
456
450
  token = tokens[i];
451
+ symbol = token[0];
457
452
 
458
- switch (token[0]) {
459
- case '#':
460
- value = context.lookup(token[1]);
453
+ if (symbol === '#') value = this._renderSection(token, context, partials, originalTemplate);
454
+ else if (symbol === '^') value = this._renderInverted(token, context, partials, originalTemplate);
455
+ else if (symbol === '>') value = this._renderPartial(token, context, partials, originalTemplate);
456
+ else if (symbol === '&') value = this._unescapedValue(token, context);
457
+ else if (symbol === 'name') value = this._escapedValue(token, context);
458
+ else if (symbol === 'text') value = this._rawValue(token);
461
459
 
462
- if (!value)
463
- continue;
460
+ if (value !== undefined)
461
+ buffer += value;
462
+ }
464
463
 
465
- if (isArray(value)) {
466
- for (var j = 0, valueLength = value.length; j < valueLength; ++j) {
467
- buffer += this.renderTokens(token[4], context.push(value[j]), partials, originalTemplate);
468
- }
469
- } else if (typeof value === 'object' || typeof value === 'string') {
470
- buffer += this.renderTokens(token[4], context.push(value), partials, originalTemplate);
471
- } else if (isFunction(value)) {
472
- if (typeof originalTemplate !== 'string')
473
- throw new Error('Cannot use higher-order sections without the original template');
464
+ return buffer;
465
+ };
474
466
 
475
- // Extract the portion of the original template that the section contains.
476
- value = value.call(context.view, originalTemplate.slice(token[3], token[5]), subRender);
467
+ Writer.prototype._renderSection = function (token, context, partials, originalTemplate) {
468
+ var self = this;
469
+ var buffer = '';
470
+ var value = context.lookup(token[1]);
477
471
 
478
- if (value != null)
479
- buffer += value;
480
- } else {
481
- buffer += this.renderTokens(token[4], context, partials, originalTemplate);
482
- }
472
+ // This function is used to render an arbitrary template
473
+ // in the current context by higher-order sections.
474
+ function subRender(template) {
475
+ return self.render(template, context, partials);
476
+ }
483
477
 
484
- break;
485
- case '^':
486
- value = context.lookup(token[1]);
478
+ if (!value) return;
487
479
 
488
- // Use JavaScript's definition of falsy. Include empty arrays.
489
- // See https://github.com/janl/mustache.js/issues/186
490
- if (!value || (isArray(value) && value.length === 0))
491
- buffer += this.renderTokens(token[4], context, partials, originalTemplate);
480
+ if (isArray(value)) {
481
+ for (var j = 0, valueLength = value.length; j < valueLength; ++j) {
482
+ buffer += this.renderTokens(token[4], context.push(value[j]), partials, originalTemplate);
483
+ }
484
+ } else if (typeof value === 'object' || typeof value === 'string') {
485
+ buffer += this.renderTokens(token[4], context.push(value), partials, originalTemplate);
486
+ } else if (isFunction(value)) {
487
+ if (typeof originalTemplate !== 'string')
488
+ throw new Error('Cannot use higher-order sections without the original template');
492
489
 
493
- break;
494
- case '>':
495
- if (!partials)
496
- continue;
490
+ // Extract the portion of the original template that the section contains.
491
+ value = value.call(context.view, originalTemplate.slice(token[3], token[5]), subRender);
497
492
 
498
- value = isFunction(partials) ? partials(token[1]) : partials[token[1]];
493
+ if (value != null)
494
+ buffer += value;
495
+ } else {
496
+ buffer += this.renderTokens(token[4], context, partials, originalTemplate);
497
+ }
498
+ return buffer;
499
+ };
499
500
 
500
- if (value != null)
501
- buffer += this.renderTokens(this.parse(value), context, partials, value);
501
+ Writer.prototype._renderInverted = function(token, context, partials, originalTemplate) {
502
+ var value = context.lookup(token[1]);
502
503
 
503
- break;
504
- case '&':
505
- value = context.lookup(token[1]);
504
+ // Use JavaScript's definition of falsy. Include empty arrays.
505
+ // See https://github.com/janl/mustache.js/issues/186
506
+ if (!value || (isArray(value) && value.length === 0))
507
+ return this.renderTokens(token[4], context, partials, originalTemplate);
508
+ };
506
509
 
507
- if (value != null)
508
- buffer += value;
510
+ Writer.prototype._renderPartial = function(token, context, partials) {
511
+ if (!partials) return;
509
512
 
510
- break;
511
- case 'name':
512
- value = context.lookup(token[1]);
513
+ var value = isFunction(partials) ? partials(token[1]) : partials[token[1]];
514
+ if (value != null)
515
+ return this.renderTokens(this.parse(value), context, partials, value);
516
+ };
513
517
 
514
- if (value != null)
515
- buffer += mustache.escape(value);
518
+ Writer.prototype._unescapedValue = function(token, context) {
519
+ var value = context.lookup(token[1]);
520
+ if (value != null)
521
+ return value;
522
+ };
516
523
 
517
- break;
518
- case 'text':
519
- buffer += token[1];
520
- break;
521
- }
522
- }
524
+ Writer.prototype._escapedValue = function(token, context) {
525
+ var value = context.lookup(token[1]);
526
+ if (value != null)
527
+ return mustache.escape(value);
528
+ };
523
529
 
524
- return buffer;
530
+ Writer.prototype._rawValue = function(token) {
531
+ return token[1];
525
532
  };
526
533
 
527
534
  mustache.name = "mustache.js";
528
- mustache.version = "1.0.0";
535
+ mustache.version = "1.1.0";
529
536
  mustache.tags = [ "{{", "}}" ];
530
537
 
531
538
  // All high-level mustache.* functions use this writer.
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mustache-js-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Krzysztof Knapik
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-23 00:00:00.000000000 Z
11
+ date: 2015-03-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties