mustache-js-rails 4.0.0 → 4.1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +5 -1
- data/lib/mustache-js-rails/version.rb +1 -1
- data/vendor/assets/javascripts/jquery.mustache.js +5 -5
- data/vendor/assets/javascripts/mustache.js +59 -26
- metadata +25 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ba03b972d4af990c40401f999c98ada8d943aad34b25fc7ed9736af9238df952
|
4
|
+
data.tar.gz: 27606c38fd81ed7e6059a4af887715676b828ef4726031f59879ea15e3238536
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0d1fc84d6c62768172b881b5911b5316eeed422f853a19cacc6cec1384f29eec37b0ec68887555832d92159e7f8550a7f27b7ee4ea05fe29ef884b074925d1cc
|
7
|
+
data.tar.gz: 78d80abe66a54f49e999fd74f7f3ea4a206baaf5afeadba62471fcddd15302f991e45db9299dbd377cad21e7b76f751c3ba79583fd7f4804bbb0f722d34708f9
|
data/README.md
CHANGED
@@ -1,11 +1,15 @@
|
|
1
1
|
# mustache-js-rails
|
2
2
|
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/mustache-js-rails.svg)][gem_version]
|
4
|
+
|
5
|
+
[gem_version]: https://rubygems.org/gems/mustache-js-rails
|
6
|
+
|
3
7
|
mustache-js-rails integrates [mustache.js](https://github.com/janl/mustache.js)
|
4
8
|
and [mustache jQuery integration](https://github.com/jonnyreeves/jquery-Mustache) with rails 3.1+ asset pipeline.
|
5
9
|
|
6
10
|
Integrated versions are:
|
7
11
|
|
8
|
-
* mustache.js - <b id="mustache-js-version">4.
|
12
|
+
* mustache.js - <b id="mustache-js-version">4.1.0</b>
|
9
13
|
* jQuery mustache - <b id="jquery-mustache-js-version">0.2.8</b>
|
10
14
|
|
11
15
|
### Installation
|
@@ -1,6 +1,6 @@
|
|
1
|
-
/*! jQuery Mustache - v0.2.8 -
|
1
|
+
/*! jQuery Mustache - v0.2.8 - 2021-06-14
|
2
2
|
* https://github.com/jonnyreeves/jquery-Mustache
|
3
|
-
* Copyright (c)
|
3
|
+
* Copyright (c) 2021 Jonny Reeves; Licensed MIT */
|
4
4
|
|
5
5
|
/*global jQuery, window */
|
6
6
|
(function ($, window) {
|
@@ -64,8 +64,8 @@
|
|
64
64
|
* Adds one or more tempaltes from the DOM using either the supplied templateElementIds or by retrieving all script
|
65
65
|
* tags of the 'domTemplateType'. Templates added in this fashion will be registered with their elementId value.
|
66
66
|
*
|
67
|
-
* @param [...templateElementIds] List of element id's present on the DOM which contain templates to be added;
|
68
|
-
* if none are supplied all script tags that are of the same type as the
|
67
|
+
* @param [...templateElementIds] List of element id's present on the DOM which contain templates to be added;
|
68
|
+
* if none are supplied all script tags that are of the same type as the
|
69
69
|
* `options.domTemplateType` configuration value will be added.
|
70
70
|
*/
|
71
71
|
function addFromDom() {
|
@@ -124,7 +124,7 @@
|
|
124
124
|
}
|
125
125
|
return '';
|
126
126
|
}
|
127
|
-
return getMustache().
|
127
|
+
return getMustache().render(templateMap[templateName], templateData, templateMap);
|
128
128
|
}
|
129
129
|
|
130
130
|
/**
|
@@ -536,14 +536,25 @@
|
|
536
536
|
* also be a function that is used to load partial templates on the fly
|
537
537
|
* that takes a single argument: the name of the partial.
|
538
538
|
*
|
539
|
-
* If the optional `
|
539
|
+
* If the optional `config` argument is given here, then it should be an
|
540
|
+
* object with a `tags` attribute or an `escape` attribute or both.
|
541
|
+
* If an array is passed, then it will be interpreted the same way as
|
542
|
+
* a `tags` attribute on a `config` object.
|
543
|
+
*
|
544
|
+
* The `tags` attribute of a `config` object must be an array with two
|
540
545
|
* string values: the opening and closing tags used in the template (e.g.
|
541
546
|
* [ "<%", "%>" ]). The default is to mustache.tags.
|
547
|
+
*
|
548
|
+
* The `escape` attribute of a `config` object must be a function which
|
549
|
+
* accepts a string as input and outputs a safely escaped string.
|
550
|
+
* If an `escape` function is not provided, then an HTML-safe string
|
551
|
+
* escaping function is used as the default.
|
542
552
|
*/
|
543
|
-
Writer.prototype.render = function render (template, view, partials,
|
553
|
+
Writer.prototype.render = function render (template, view, partials, config) {
|
554
|
+
var tags = this.getConfigTags(config);
|
544
555
|
var tokens = this.parse(template, tags);
|
545
556
|
var context = (view instanceof Context) ? view : new Context(view, undefined);
|
546
|
-
return this.renderTokens(tokens, context, partials, template,
|
557
|
+
return this.renderTokens(tokens, context, partials, template, config);
|
547
558
|
};
|
548
559
|
|
549
560
|
/**
|
@@ -555,7 +566,7 @@
|
|
555
566
|
* If the template doesn't use higher-order sections, this argument may
|
556
567
|
* be omitted.
|
557
568
|
*/
|
558
|
-
Writer.prototype.renderTokens = function renderTokens (tokens, context, partials, originalTemplate,
|
569
|
+
Writer.prototype.renderTokens = function renderTokens (tokens, context, partials, originalTemplate, config) {
|
559
570
|
var buffer = '';
|
560
571
|
|
561
572
|
var token, symbol, value;
|
@@ -564,11 +575,11 @@
|
|
564
575
|
token = tokens[i];
|
565
576
|
symbol = token[0];
|
566
577
|
|
567
|
-
if (symbol === '#') value = this.renderSection(token, context, partials, originalTemplate);
|
568
|
-
else if (symbol === '^') value = this.renderInverted(token, context, partials, originalTemplate);
|
569
|
-
else if (symbol === '>') value = this.renderPartial(token, context, partials,
|
578
|
+
if (symbol === '#') value = this.renderSection(token, context, partials, originalTemplate, config);
|
579
|
+
else if (symbol === '^') value = this.renderInverted(token, context, partials, originalTemplate, config);
|
580
|
+
else if (symbol === '>') value = this.renderPartial(token, context, partials, config);
|
570
581
|
else if (symbol === '&') value = this.unescapedValue(token, context);
|
571
|
-
else if (symbol === 'name') value = this.escapedValue(token, context);
|
582
|
+
else if (symbol === 'name') value = this.escapedValue(token, context, config);
|
572
583
|
else if (symbol === 'text') value = this.rawValue(token);
|
573
584
|
|
574
585
|
if (value !== undefined)
|
@@ -578,7 +589,7 @@
|
|
578
589
|
return buffer;
|
579
590
|
};
|
580
591
|
|
581
|
-
Writer.prototype.renderSection = function renderSection (token, context, partials, originalTemplate) {
|
592
|
+
Writer.prototype.renderSection = function renderSection (token, context, partials, originalTemplate, config) {
|
582
593
|
var self = this;
|
583
594
|
var buffer = '';
|
584
595
|
var value = context.lookup(token[1]);
|
@@ -586,17 +597,17 @@
|
|
586
597
|
// This function is used to render an arbitrary template
|
587
598
|
// in the current context by higher-order sections.
|
588
599
|
function subRender (template) {
|
589
|
-
return self.render(template, context, partials);
|
600
|
+
return self.render(template, context, partials, config);
|
590
601
|
}
|
591
602
|
|
592
603
|
if (!value) return;
|
593
604
|
|
594
605
|
if (isArray(value)) {
|
595
606
|
for (var j = 0, valueLength = value.length; j < valueLength; ++j) {
|
596
|
-
buffer += this.renderTokens(token[4], context.push(value[j]), partials, originalTemplate);
|
607
|
+
buffer += this.renderTokens(token[4], context.push(value[j]), partials, originalTemplate, config);
|
597
608
|
}
|
598
609
|
} else if (typeof value === 'object' || typeof value === 'string' || typeof value === 'number') {
|
599
|
-
buffer += this.renderTokens(token[4], context.push(value), partials, originalTemplate);
|
610
|
+
buffer += this.renderTokens(token[4], context.push(value), partials, originalTemplate, config);
|
600
611
|
} else if (isFunction(value)) {
|
601
612
|
if (typeof originalTemplate !== 'string')
|
602
613
|
throw new Error('Cannot use higher-order sections without the original template');
|
@@ -607,18 +618,18 @@
|
|
607
618
|
if (value != null)
|
608
619
|
buffer += value;
|
609
620
|
} else {
|
610
|
-
buffer += this.renderTokens(token[4], context, partials, originalTemplate);
|
621
|
+
buffer += this.renderTokens(token[4], context, partials, originalTemplate, config);
|
611
622
|
}
|
612
623
|
return buffer;
|
613
624
|
};
|
614
625
|
|
615
|
-
Writer.prototype.renderInverted = function renderInverted (token, context, partials, originalTemplate) {
|
626
|
+
Writer.prototype.renderInverted = function renderInverted (token, context, partials, originalTemplate, config) {
|
616
627
|
var value = context.lookup(token[1]);
|
617
628
|
|
618
629
|
// Use JavaScript's definition of falsy. Include empty arrays.
|
619
630
|
// See https://github.com/janl/mustache.js/issues/186
|
620
631
|
if (!value || (isArray(value) && value.length === 0))
|
621
|
-
return this.renderTokens(token[4], context, partials, originalTemplate);
|
632
|
+
return this.renderTokens(token[4], context, partials, originalTemplate, config);
|
622
633
|
};
|
623
634
|
|
624
635
|
Writer.prototype.indentPartial = function indentPartial (partial, indentation, lineHasNonSpace) {
|
@@ -632,8 +643,9 @@
|
|
632
643
|
return partialByNl.join('\n');
|
633
644
|
};
|
634
645
|
|
635
|
-
Writer.prototype.renderPartial = function renderPartial (token, context, partials,
|
646
|
+
Writer.prototype.renderPartial = function renderPartial (token, context, partials, config) {
|
636
647
|
if (!partials) return;
|
648
|
+
var tags = this.getConfigTags(config);
|
637
649
|
|
638
650
|
var value = isFunction(partials) ? partials(token[1]) : partials[token[1]];
|
639
651
|
if (value != null) {
|
@@ -644,7 +656,8 @@
|
|
644
656
|
if (tagIndex == 0 && indentation) {
|
645
657
|
indentedValue = this.indentPartial(value, indentation, lineHasNonSpace);
|
646
658
|
}
|
647
|
-
|
659
|
+
var tokens = this.parse(indentedValue, tags);
|
660
|
+
return this.renderTokens(tokens, context, partials, indentedValue, config);
|
648
661
|
}
|
649
662
|
};
|
650
663
|
|
@@ -654,19 +667,41 @@
|
|
654
667
|
return value;
|
655
668
|
};
|
656
669
|
|
657
|
-
Writer.prototype.escapedValue = function escapedValue (token, context) {
|
670
|
+
Writer.prototype.escapedValue = function escapedValue (token, context, config) {
|
671
|
+
var escape = this.getConfigEscape(config) || mustache.escape;
|
658
672
|
var value = context.lookup(token[1]);
|
659
673
|
if (value != null)
|
660
|
-
return mustache.escape(value);
|
674
|
+
return (typeof value === 'number' && escape === mustache.escape) ? String(value) : escape(value);
|
661
675
|
};
|
662
676
|
|
663
677
|
Writer.prototype.rawValue = function rawValue (token) {
|
664
678
|
return token[1];
|
665
679
|
};
|
666
680
|
|
681
|
+
Writer.prototype.getConfigTags = function getConfigTags (config) {
|
682
|
+
if (isArray(config)) {
|
683
|
+
return config;
|
684
|
+
}
|
685
|
+
else if (config && typeof config === 'object') {
|
686
|
+
return config.tags;
|
687
|
+
}
|
688
|
+
else {
|
689
|
+
return undefined;
|
690
|
+
}
|
691
|
+
};
|
692
|
+
|
693
|
+
Writer.prototype.getConfigEscape = function getConfigEscape (config) {
|
694
|
+
if (config && typeof config === 'object' && !isArray(config)) {
|
695
|
+
return config.escape;
|
696
|
+
}
|
697
|
+
else {
|
698
|
+
return undefined;
|
699
|
+
}
|
700
|
+
};
|
701
|
+
|
667
702
|
var mustache = {
|
668
703
|
name: 'mustache.js',
|
669
|
-
version: '4.
|
704
|
+
version: '4.1.0',
|
670
705
|
tags: [ '{{', '}}' ],
|
671
706
|
clearCache: undefined,
|
672
707
|
escape: undefined,
|
@@ -711,19 +746,17 @@
|
|
711
746
|
};
|
712
747
|
|
713
748
|
/**
|
714
|
-
* Renders the `template` with the given `view` and `
|
715
|
-
* default writer.
|
716
|
-
* array with two string values: the opening and closing tags used in the
|
717
|
-
* template (e.g. [ "<%", "%>" ]). The default is to mustache.tags.
|
749
|
+
* Renders the `template` with the given `view`, `partials`, and `config`
|
750
|
+
* using the default writer.
|
718
751
|
*/
|
719
|
-
mustache.render = function render (template, view, partials,
|
752
|
+
mustache.render = function render (template, view, partials, config) {
|
720
753
|
if (typeof template !== 'string') {
|
721
754
|
throw new TypeError('Invalid template! Template should be a "string" ' +
|
722
755
|
'but "' + typeStr(template) + '" was given as the first ' +
|
723
756
|
'argument for mustache#render(template, view, partials)');
|
724
757
|
}
|
725
758
|
|
726
|
-
return defaultWriter.render(template, view, partials,
|
759
|
+
return defaultWriter.render(template, view, partials, config);
|
727
760
|
};
|
728
761
|
|
729
762
|
// Export the escaping function so that the user may override it.
|
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: 4.0.
|
4
|
+
version: 4.1.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Krzysztof Knapik
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-06-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|
@@ -28,17 +28,31 @@ dependencies:
|
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: release
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
39
53
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
41
|
-
description:
|
54
|
+
version: '0'
|
55
|
+
description:
|
42
56
|
email:
|
43
57
|
- knapo@knapo.net
|
44
58
|
executables: []
|
@@ -59,7 +73,7 @@ licenses:
|
|
59
73
|
metadata:
|
60
74
|
homepage_uri: https://github.com/knapo/mustache-js-rails
|
61
75
|
source_code_uri: https://github.com/knapo/mustache-js-rails
|
62
|
-
post_install_message:
|
76
|
+
post_install_message:
|
63
77
|
rdoc_options: []
|
64
78
|
require_paths:
|
65
79
|
- lib
|
@@ -74,8 +88,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
74
88
|
- !ruby/object:Gem::Version
|
75
89
|
version: '0'
|
76
90
|
requirements: []
|
77
|
-
rubygems_version: 3.
|
78
|
-
signing_key:
|
91
|
+
rubygems_version: 3.2.19
|
92
|
+
signing_key:
|
79
93
|
specification_version: 4
|
80
94
|
summary: mustache.js and jQuery.mustache.js integration for Rails 3.1+ asset pipeline
|
81
95
|
test_files: []
|