Quellcode durchsuchen

Consistent undefined check and default test cache

pull/731/head
Andrew Leedham vor 6 Jahren
Ursprung
Commit
c81d32ee38
4 geänderte Dateien mit 19 neuen und 15 gelöschten Zeilen
  1. +6
    -1
      mustache.js
  2. +1
    -1
      mustache.min.js
  3. +6
    -1
      mustache.mjs
  4. +6
    -12
      test/parse-test.js

+ 6
- 1
mustache.js Datei anzeigen

@@ -504,7 +504,9 @@
* Clears all cached templates in this writer.
*/
Writer.prototype.clearCache = function clearCache () {
this.templateCache !== undefined && this.templateCache.clear();
if (typeof this.templateCache !== 'undefined') {
this.templateCache.clear();
}
};

/**
@@ -676,6 +678,9 @@
Writer: undefined,
set templateCache (cache) {
defaultWriter.templateCache = cache;
},
get templateCache () {
return defaultWriter.templateCache;
}
};



+ 1
- 1
mustache.min.js
Datei-Diff unterdrückt, da er zu groß ist
Datei anzeigen


+ 6
- 1
mustache.mjs Datei anzeigen

@@ -497,7 +497,9 @@ function Writer () {
* Clears all cached templates in this writer.
*/
Writer.prototype.clearCache = function clearCache () {
this.templateCache !== undefined && this.templateCache.clear();
if (typeof this.templateCache !== 'undefined') {
this.templateCache.clear();
}
};

/**
@@ -669,6 +671,9 @@ var mustache = {
Writer: undefined,
set templateCache (cache) {
defaultWriter.templateCache = cache;
},
get templateCache () {
return defaultWriter.templateCache;
}
};



+ 6
- 12
test/parse-test.js Datei anzeigen

@@ -56,20 +56,14 @@ var expectations = {
: [ [ '#', 'foo', 0, 8, [ [ '#', 'a', 11, 17, [ [ 'text', ' ', 18, 22 ], [ 'name', 'b', 22, 27 ], [ 'text', '\n', 27, 28 ] ], 30 ] ], 37 ] ]
};

var originalTemplateCache;
before(function () {
originalTemplateCache = Mustache.templateCache;
});

beforeEach(function (){
Mustache.clearCache();
Mustache.templateCache = {
_cache: {},
set: function set (key, value) {
this._cache[key] = value;
},
get: function get (key) {
return this._cache[key];
},
clear: function clear () {
this._cache = {};
}
};
Mustache.templateCache = originalTemplateCache;
});

describe('Mustache.parse', function () {


Laden…
Abbrechen
Speichern