mustache-js-rails 3.0.1 → 4.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6d3a389059cbfd17f2caddb9e1225a24307ad604c79827d332d611ed0b28341b
4
- data.tar.gz: 78ebf3e7d410e4d2f264814db50dd37e19ea1329b5e43d3df442b2156abd880d
3
+ metadata.gz: bdaacb9d86224bfaad91faadf214d54fba2aff3061782daa0f94db8699337a00
4
+ data.tar.gz: 43565772ac94156221a0ba5b35bd2f3993e667db3e8502ee78b0b370e7ef8b23
5
5
  SHA512:
6
- metadata.gz: 0c819e72f01a9029f71217d90c4c0172cd55557da81e0e84a870147cbe9acb4d34806f0a4694f2afd19f98c7837e1c889f8b3aee79a0c9c67769749e06fd8d0e
7
- data.tar.gz: 581f85c21a646b0bd3b2b4862a3db0094a61271d891d98e1180ac5feada6033ff40bb34b8f757fa66942995c75aedf4a404b9f40bca7cc083188fc8d6e55dbff
6
+ metadata.gz: ff21d26afa01b0542780f8ce26dc0e796c165e797e57a659ede1d1ff20b38b1456bbb297b5208938076680101880dccdf3a0b776772405586d34ef0ede087d5c
7
+ data.tar.gz: 204506a54896719b4a81cf4baaeefe3422523b766c31dcd1c34f4d7d2d43158f9897061b558c8d5d72a1c704b231bd6035c7730c9961c84e49ad3d1f10acc3f3
File without changes
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">3.0.1</b>
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,3 +1,3 @@
1
1
  module MustacheJsRails
2
- VERSION = "3.0.1"
2
+ VERSION = "4.1.0"
3
3
  end
@@ -1,20 +1,14 @@
1
- /*!
2
- * mustache.js - Logic-less {{mustache}} templates with JavaScript
3
- * http://github.com/janl/mustache.js
4
- */
5
-
6
- /*global define: false Mustache: true*/
7
-
8
- (function defineMustache (global, factory) {
9
- if (typeof exports === 'object' && exports && typeof exports.nodeName !== 'string') {
10
- factory(exports); // CommonJS
11
- } else if (typeof define === 'function' && define.amd) {
12
- define(['exports'], factory); // AMD
13
- } else {
14
- global.Mustache = {};
15
- factory(global.Mustache); // script, wsh, asp
16
- }
17
- }(this, function mustacheFactory (mustache) {
1
+ // This file has been generated from mustache.mjs
2
+ (function (global, factory) {
3
+ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
4
+ typeof define === 'function' && define.amd ? define(factory) :
5
+ (global = global || self, global.Mustache = factory());
6
+ }(this, (function () { 'use strict';
7
+
8
+ /*!
9
+ * mustache.js - Logic-less {{mustache}} templates with JavaScript
10
+ * http://github.com/janl/mustache.js
11
+ */
18
12
 
19
13
  var objectToString = Object.prototype.toString;
20
14
  var isArray = Array.isArray || function isArrayPolyfill (object) {
@@ -49,7 +43,7 @@
49
43
  * Safe way of detecting whether or not the given thing is a primitive and
50
44
  * whether it has the given property
51
45
  */
52
- function primitiveHasOwnProperty (primitive, propName) {
46
+ function primitiveHasOwnProperty (primitive, propName) {
53
47
  return (
54
48
  primitive != null
55
49
  && typeof primitive !== 'object'
@@ -114,16 +108,22 @@
114
108
  * Tokens that are the root node of a subtree contain two more elements: 1) an
115
109
  * array of tokens in the subtree and 2) the index in the original template at
116
110
  * which the closing tag for that section begins.
111
+ *
112
+ * Tokens for partials also contain two more elements: 1) a string value of
113
+ * indendation prior to that tag and 2) the index of that tag on that line -
114
+ * eg a value of 2 indicates the partial is the third tag on this line.
117
115
  */
118
116
  function parseTemplate (template, tags) {
119
117
  if (!template)
120
118
  return [];
121
-
119
+ var lineHasNonSpace = false;
122
120
  var sections = []; // Stack to hold section tokens
123
121
  var tokens = []; // Buffer to hold the tokens
124
122
  var spaces = []; // Indices of whitespace tokens on the current line
125
123
  var hasTag = false; // Is there a {{tag}} on the current line?
126
124
  var nonSpace = false; // Is there a non-space char on the current line?
125
+ var indentation = ''; // Tracks indentation for tags that use it
126
+ var tagIndex = 0; // Stores a count of number of tags encountered on a line
127
127
 
128
128
  // Strips all whitespace tokens array for the current line
129
129
  // if there was a {{#tag}} on it and otherwise only space.
@@ -169,16 +169,23 @@
169
169
 
170
170
  if (isWhitespace(chr)) {
171
171
  spaces.push(tokens.length);
172
+ indentation += chr;
172
173
  } else {
173
174
  nonSpace = true;
175
+ lineHasNonSpace = true;
176
+ indentation += ' ';
174
177
  }
175
178
 
176
179
  tokens.push([ 'text', chr, start, start + 1 ]);
177
180
  start += 1;
178
181
 
179
182
  // Check for whitespace on the current line.
180
- if (chr === '\n')
183
+ if (chr === '\n') {
181
184
  stripSpace();
185
+ indentation = '';
186
+ tagIndex = 0;
187
+ lineHasNonSpace = false;
188
+ }
182
189
  }
183
190
  }
184
191
 
@@ -210,7 +217,12 @@
210
217
  if (!scanner.scan(closingTagRe))
211
218
  throw new Error('Unclosed tag at ' + scanner.pos);
212
219
 
213
- token = [ type, value, start, scanner.pos ];
220
+ if (type == '>') {
221
+ token = [ type, value, start, scanner.pos, indentation, tagIndex, lineHasNonSpace ];
222
+ } else {
223
+ token = [ type, value, start, scanner.pos ];
224
+ }
225
+ tagIndex++;
214
226
  tokens.push(token);
215
227
 
216
228
  if (type === '#' || type === '^') {
@@ -232,6 +244,8 @@
232
244
  }
233
245
  }
234
246
 
247
+ stripSpace();
248
+
235
249
  // Make sure there are no open sections when we're done.
236
250
  openSection = sections.pop();
237
251
 
@@ -418,7 +432,7 @@
418
432
  while (intermediateValue != null && index < names.length) {
419
433
  if (index === names.length - 1)
420
434
  lookupHit = (
421
- hasProperty(intermediateValue, names[index])
435
+ hasProperty(intermediateValue, names[index])
422
436
  || primitiveHasOwnProperty(intermediateValue, names[index])
423
437
  );
424
438
 
@@ -472,14 +486,27 @@
472
486
  * avoid the need to parse the same template twice.
473
487
  */
474
488
  function Writer () {
475
- this.cache = {};
489
+ this.templateCache = {
490
+ _cache: {},
491
+ set: function set (key, value) {
492
+ this._cache[key] = value;
493
+ },
494
+ get: function get (key) {
495
+ return this._cache[key];
496
+ },
497
+ clear: function clear () {
498
+ this._cache = {};
499
+ }
500
+ };
476
501
  }
477
502
 
478
503
  /**
479
504
  * Clears all cached templates in this writer.
480
505
  */
481
506
  Writer.prototype.clearCache = function clearCache () {
482
- this.cache = {};
507
+ if (typeof this.templateCache !== 'undefined') {
508
+ this.templateCache.clear();
509
+ }
483
510
  };
484
511
 
485
512
  /**
@@ -488,13 +515,15 @@
488
515
  * that is generated from the parse.
489
516
  */
490
517
  Writer.prototype.parse = function parse (template, tags) {
491
- var cache = this.cache;
518
+ var cache = this.templateCache;
492
519
  var cacheKey = template + ':' + (tags || mustache.tags).join(':');
493
- var tokens = cache[cacheKey];
494
-
495
- if (tokens == null)
496
- tokens = cache[cacheKey] = parseTemplate(template, tags);
520
+ var isCacheEnabled = typeof cache !== 'undefined';
521
+ var tokens = isCacheEnabled ? cache.get(cacheKey) : undefined;
497
522
 
523
+ if (tokens == undefined) {
524
+ tokens = parseTemplate(template, tags);
525
+ isCacheEnabled && cache.set(cacheKey, tokens);
526
+ }
498
527
  return tokens;
499
528
  };
500
529
 
@@ -507,14 +536,25 @@
507
536
  * also be a function that is used to load partial templates on the fly
508
537
  * that takes a single argument: the name of the partial.
509
538
  *
510
- * If the optional `tags` argument is given here it must be an array with two
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
511
545
  * string values: the opening and closing tags used in the template (e.g.
512
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.
513
552
  */
514
- Writer.prototype.render = function render (template, view, partials, tags) {
553
+ Writer.prototype.render = function render (template, view, partials, config) {
554
+ var tags = this.getConfigTags(config);
515
555
  var tokens = this.parse(template, tags);
516
- var context = (view instanceof Context) ? view : new Context(view);
517
- return this.renderTokens(tokens, context, partials, template, tags);
556
+ var context = (view instanceof Context) ? view : new Context(view, undefined);
557
+ return this.renderTokens(tokens, context, partials, template, config);
518
558
  };
519
559
 
520
560
  /**
@@ -526,7 +566,7 @@
526
566
  * If the template doesn't use higher-order sections, this argument may
527
567
  * be omitted.
528
568
  */
529
- Writer.prototype.renderTokens = function renderTokens (tokens, context, partials, originalTemplate, tags) {
569
+ Writer.prototype.renderTokens = function renderTokens (tokens, context, partials, originalTemplate, config) {
530
570
  var buffer = '';
531
571
 
532
572
  var token, symbol, value;
@@ -535,11 +575,11 @@
535
575
  token = tokens[i];
536
576
  symbol = token[0];
537
577
 
538
- if (symbol === '#') value = this.renderSection(token, context, partials, originalTemplate);
539
- else if (symbol === '^') value = this.renderInverted(token, context, partials, originalTemplate);
540
- else if (symbol === '>') value = this.renderPartial(token, context, partials, tags);
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);
541
581
  else if (symbol === '&') value = this.unescapedValue(token, context);
542
- else if (symbol === 'name') value = this.escapedValue(token, context);
582
+ else if (symbol === 'name') value = this.escapedValue(token, context, config);
543
583
  else if (symbol === 'text') value = this.rawValue(token);
544
584
 
545
585
  if (value !== undefined)
@@ -549,7 +589,7 @@
549
589
  return buffer;
550
590
  };
551
591
 
552
- Writer.prototype.renderSection = function renderSection (token, context, partials, originalTemplate) {
592
+ Writer.prototype.renderSection = function renderSection (token, context, partials, originalTemplate, config) {
553
593
  var self = this;
554
594
  var buffer = '';
555
595
  var value = context.lookup(token[1]);
@@ -557,17 +597,17 @@
557
597
  // This function is used to render an arbitrary template
558
598
  // in the current context by higher-order sections.
559
599
  function subRender (template) {
560
- return self.render(template, context, partials);
600
+ return self.render(template, context, partials, config);
561
601
  }
562
602
 
563
603
  if (!value) return;
564
604
 
565
605
  if (isArray(value)) {
566
606
  for (var j = 0, valueLength = value.length; j < valueLength; ++j) {
567
- buffer += this.renderTokens(token[4], context.push(value[j]), partials, originalTemplate);
607
+ buffer += this.renderTokens(token[4], context.push(value[j]), partials, originalTemplate, config);
568
608
  }
569
609
  } else if (typeof value === 'object' || typeof value === 'string' || typeof value === 'number') {
570
- buffer += this.renderTokens(token[4], context.push(value), partials, originalTemplate);
610
+ buffer += this.renderTokens(token[4], context.push(value), partials, originalTemplate, config);
571
611
  } else if (isFunction(value)) {
572
612
  if (typeof originalTemplate !== 'string')
573
613
  throw new Error('Cannot use higher-order sections without the original template');
@@ -578,26 +618,47 @@
578
618
  if (value != null)
579
619
  buffer += value;
580
620
  } else {
581
- buffer += this.renderTokens(token[4], context, partials, originalTemplate);
621
+ buffer += this.renderTokens(token[4], context, partials, originalTemplate, config);
582
622
  }
583
623
  return buffer;
584
624
  };
585
625
 
586
- Writer.prototype.renderInverted = function renderInverted (token, context, partials, originalTemplate) {
626
+ Writer.prototype.renderInverted = function renderInverted (token, context, partials, originalTemplate, config) {
587
627
  var value = context.lookup(token[1]);
588
628
 
589
629
  // Use JavaScript's definition of falsy. Include empty arrays.
590
630
  // See https://github.com/janl/mustache.js/issues/186
591
631
  if (!value || (isArray(value) && value.length === 0))
592
- return this.renderTokens(token[4], context, partials, originalTemplate);
632
+ return this.renderTokens(token[4], context, partials, originalTemplate, config);
593
633
  };
594
634
 
595
- Writer.prototype.renderPartial = function renderPartial (token, context, partials, tags) {
635
+ Writer.prototype.indentPartial = function indentPartial (partial, indentation, lineHasNonSpace) {
636
+ var filteredIndentation = indentation.replace(/[^ \t]/g, '');
637
+ var partialByNl = partial.split('\n');
638
+ for (var i = 0; i < partialByNl.length; i++) {
639
+ if (partialByNl[i].length && (i > 0 || !lineHasNonSpace)) {
640
+ partialByNl[i] = filteredIndentation + partialByNl[i];
641
+ }
642
+ }
643
+ return partialByNl.join('\n');
644
+ };
645
+
646
+ Writer.prototype.renderPartial = function renderPartial (token, context, partials, config) {
596
647
  if (!partials) return;
648
+ var tags = this.getConfigTags(config);
597
649
 
598
650
  var value = isFunction(partials) ? partials(token[1]) : partials[token[1]];
599
- if (value != null)
600
- return this.renderTokens(this.parse(value, tags), context, partials, value);
651
+ if (value != null) {
652
+ var lineHasNonSpace = token[6];
653
+ var tagIndex = token[5];
654
+ var indentation = token[4];
655
+ var indentedValue = value;
656
+ if (tagIndex == 0 && indentation) {
657
+ indentedValue = this.indentPartial(value, indentation, lineHasNonSpace);
658
+ }
659
+ var tokens = this.parse(indentedValue, tags);
660
+ return this.renderTokens(tokens, context, partials, indentedValue, config);
661
+ }
601
662
  };
602
663
 
603
664
  Writer.prototype.unescapedValue = function unescapedValue (token, context) {
@@ -606,19 +667,64 @@
606
667
  return value;
607
668
  };
608
669
 
609
- Writer.prototype.escapedValue = function escapedValue (token, context) {
670
+ Writer.prototype.escapedValue = function escapedValue (token, context, config) {
671
+ var escape = this.getConfigEscape(config) || mustache.escape;
610
672
  var value = context.lookup(token[1]);
611
673
  if (value != null)
612
- return mustache.escape(value);
674
+ return (typeof value === 'number' && escape === mustache.escape) ? String(value) : escape(value);
613
675
  };
614
676
 
615
677
  Writer.prototype.rawValue = function rawValue (token) {
616
678
  return token[1];
617
679
  };
618
680
 
619
- mustache.name = 'mustache.js';
620
- mustache.version = '3.0.1';
621
- mustache.tags = [ '{{', '}}' ];
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
+
702
+ var mustache = {
703
+ name: 'mustache.js',
704
+ version: '4.1.0',
705
+ tags: [ '{{', '}}' ],
706
+ clearCache: undefined,
707
+ escape: undefined,
708
+ parse: undefined,
709
+ render: undefined,
710
+ Scanner: undefined,
711
+ Context: undefined,
712
+ Writer: undefined,
713
+ /**
714
+ * Allows a user to override the default caching strategy, by providing an
715
+ * object with set, get and clear methods. This can also be used to disable
716
+ * the cache by setting it to the literal `undefined`.
717
+ */
718
+ set templateCache (cache) {
719
+ defaultWriter.templateCache = cache;
720
+ },
721
+ /**
722
+ * Gets the default or overridden caching object from the default writer.
723
+ */
724
+ get templateCache () {
725
+ return defaultWriter.templateCache;
726
+ }
727
+ };
622
728
 
623
729
  // All high-level mustache.* functions use this writer.
624
730
  var defaultWriter = new Writer();
@@ -640,33 +746,17 @@
640
746
  };
641
747
 
642
748
  /**
643
- * Renders the `template` with the given `view` and `partials` using the
644
- * default writer. If the optional `tags` argument is given here it must be an
645
- * array with two string values: the opening and closing tags used in the
646
- * 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.
647
751
  */
648
- mustache.render = function render (template, view, partials, tags) {
752
+ mustache.render = function render (template, view, partials, config) {
649
753
  if (typeof template !== 'string') {
650
754
  throw new TypeError('Invalid template! Template should be a "string" ' +
651
755
  'but "' + typeStr(template) + '" was given as the first ' +
652
756
  'argument for mustache#render(template, view, partials)');
653
757
  }
654
758
 
655
- return defaultWriter.render(template, view, partials, tags);
656
- };
657
-
658
- // This is here for backwards compatibility with 0.4.x.,
659
- /*eslint-disable */ // eslint wants camel cased function name
660
- mustache.to_html = function to_html (template, view, partials, send) {
661
- /*eslint-enable*/
662
-
663
- var result = mustache.render(template, view, partials);
664
-
665
- if (isFunction(send)) {
666
- send(result);
667
- } else {
668
- return result;
669
- }
759
+ return defaultWriter.render(template, view, partials, config);
670
760
  };
671
761
 
672
762
  // Export the escaping function so that the user may override it.
@@ -679,4 +769,5 @@
679
769
  mustache.Writer = Writer;
680
770
 
681
771
  return mustache;
682
- }));
772
+
773
+ })));
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: 3.0.1
4
+ version: 4.1.0
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: 2019-01-02 00:00:00.000000000 Z
11
+ date: 2021-03-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties
@@ -17,9 +17,6 @@ dependencies:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '3.1'
20
- - - "<"
21
- - !ruby/object:Gem::Version
22
- version: '6'
23
20
  type: :runtime
24
21
  prerelease: false
25
22
  version_requirements: !ruby/object:Gem::Requirement
@@ -27,12 +24,21 @@ dependencies:
27
24
  - - ">="
28
25
  - !ruby/object:Gem::Version
29
26
  version: '3.1'
30
- - - "<"
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
31
32
  - !ruby/object:Gem::Version
32
- version: '6'
33
- description: "\n mustache.js (https://github.com/janl/mustache.js)\n and jQuery.mustache.js
34
- (https://github.com/jonnyreeves/jquery-Mustache)\n for Rails 3.1+ asset pipeline\n
35
- \ "
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description:
36
42
  email:
37
43
  - knapo@knapo.net
38
44
  executables: []
@@ -40,9 +46,8 @@ extensions: []
40
46
  extra_rdoc_files: []
41
47
  files:
42
48
  - Gemfile
43
- - MIT-LICENSE
49
+ - LICENSE
44
50
  - README.md
45
- - Rakefile
46
51
  - lib/mustache-js-rails.rb
47
52
  - lib/mustache-js-rails/engine.rb
48
53
  - lib/mustache-js-rails/version.rb
@@ -51,8 +56,10 @@ files:
51
56
  homepage: https://github.com/knapo/mustache-js-rails
52
57
  licenses:
53
58
  - MIT
54
- metadata: {}
55
- post_install_message:
59
+ metadata:
60
+ homepage_uri: https://github.com/knapo/mustache-js-rails
61
+ source_code_uri: https://github.com/knapo/mustache-js-rails
62
+ post_install_message:
56
63
  rdoc_options: []
57
64
  require_paths:
58
65
  - lib
@@ -60,16 +67,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
60
67
  requirements:
61
68
  - - ">="
62
69
  - !ruby/object:Gem::Version
63
- version: '0'
70
+ version: 2.0.0
64
71
  required_rubygems_version: !ruby/object:Gem::Requirement
65
72
  requirements:
66
73
  - - ">="
67
74
  - !ruby/object:Gem::Version
68
75
  version: '0'
69
76
  requirements: []
70
- rubyforge_project: mustache-js-rails
71
- rubygems_version: 2.7.7
72
- signing_key:
77
+ rubygems_version: 3.2.9
78
+ signing_key:
73
79
  specification_version: 4
74
- summary: mustache.js and jQuery.mustache.js for Rails 3.1+ asset pipeline
80
+ summary: mustache.js and jQuery.mustache.js integration for Rails 3.1+ asset pipeline
75
81
  test_files: []
data/Rakefile DELETED
@@ -1,32 +0,0 @@
1
- #!/usr/bin/env rake
2
- require 'bundler/gem_tasks'
3
-
4
- task :update do
5
- Dir['*.gem'].each{ |f| FileUtils.rm(f) }
6
-
7
- js_dir = 'vendor/assets/javascripts'
8
- css_dir = 'vendor/assets/stylesheets'
9
- img_dir = 'vendor/assets/images'
10
- [js_dir, css_dir, img_dir].each do |dir|
11
- FileUtils.rm_r(dir)
12
- FileUtils.mkdir(dir)
13
- FileUtils.touch(File.join(dir, '.gitkeep'))
14
- end
15
-
16
- puts 'Updating source files...'
17
- `git submodule update --recursive --remote`
18
-
19
- puts 'Copying source js files...'
20
- FileUtils.cp('mustache.js/mustache.js', js_dir)
21
- FileUtils.cp('jquery.mustache.js/jquery.mustache.js', js_dir)
22
-
23
- puts 'Updating version...'
24
- mustache_js_version = File.read('mustache.js/mustache.js.nuspec').match(/<version>([\.\d]+)<\/version>/)[1]
25
- jquery_mustache_js_version = File.read('jquery.mustache.js/jquery.mustache.js').match(/jQuery Mustache - v([\.\d]+)/)[1]
26
- puts "Current mustache.js version is: #{mustache_js_version}"
27
- puts "Current jquery.mustache.js version is: #{jquery_mustache_js_version}"
28
- readme = File.read('README.md')
29
- readme = readme.gsub(/(?<=<b id="mustache-js-version">)[\d\.]+(?=<\/b>)/, mustache_js_version)
30
- readme = readme.gsub(/(?<=<b id="jquery-mustache-js-version">)[\d\.]+(?=<\/b>)/, jquery_mustache_js_version)
31
- File.open('README.md','w') { |f| f.write(readme) }
32
- end