mustache-js-rails 1.0.0 → 1.1.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.
Potentially problematic release.
This version of mustache-js-rails might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/Rakefile +3 -1
- data/lib/mustache-js-rails/version.rb +1 -1
- data/vendor/assets/javascripts/mustache.js +68 -61
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d658a53c1a9063220c7daf0d0a9ba752fec30531
|
4
|
+
data.tar.gz: ce7b2dd677355aad2e6a45deaf819cbaad132ac1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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.
|
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
|
@@ -444,88 +444,95 @@
|
|
444
444
|
Writer.prototype.renderTokens = function (tokens, context, partials, originalTemplate) {
|
445
445
|
var buffer = '';
|
446
446
|
|
447
|
-
|
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
|
-
|
459
|
-
|
460
|
-
|
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
|
-
|
463
|
-
|
460
|
+
if (value !== undefined)
|
461
|
+
buffer += value;
|
462
|
+
}
|
464
463
|
|
465
|
-
|
466
|
-
|
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
|
-
|
476
|
-
|
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
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
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
|
-
|
485
|
-
case '^':
|
486
|
-
value = context.lookup(token[1]);
|
478
|
+
if (!value) return;
|
487
479
|
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
|
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
|
-
|
494
|
-
|
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
|
-
|
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
|
-
|
501
|
-
|
501
|
+
Writer.prototype._renderInverted = function(token, context, partials, originalTemplate) {
|
502
|
+
var value = context.lookup(token[1]);
|
502
503
|
|
503
|
-
|
504
|
-
|
505
|
-
|
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
|
-
|
508
|
-
|
510
|
+
Writer.prototype._renderPartial = function(token, context, partials) {
|
511
|
+
if (!partials) return;
|
509
512
|
|
510
|
-
|
511
|
-
|
512
|
-
|
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
|
-
|
515
|
-
|
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
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
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
|
-
|
530
|
+
Writer.prototype._rawValue = function(token) {
|
531
|
+
return token[1];
|
525
532
|
};
|
526
533
|
|
527
534
|
mustache.name = "mustache.js";
|
528
|
-
mustache.version = "1.
|
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.
|
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:
|
11
|
+
date: 2015-03-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|