Skip to content

Commit

Permalink
Merge pull request #3233 from OpenTreeMap/jcw/js-deps
Browse files Browse the repository at this point in the history
Upgrade JS dependencies
  • Loading branch information
jwalgran committed Feb 15, 2018
2 parents 65df4eb + 0716685 commit 48be16c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 9 deletions.
13 changes: 7 additions & 6 deletions opentreemap/manage_treemap/js/src/lib/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ var $ = require('jquery'),
_ = require('lodash'),
mustache = require('mustache');

var fieldErrorsTemplate = mustache.compile(
$('#field-error-template').html());
var fieldErrorsTemplate = $('#field-error-template').html();
var globalErrorsTemplate = $('#global-errors-template').html();

var globalErrorsTemplate = mustache.compile(
$('#global-errors-template').html());
// Parsing speeds up future, repeated usages of the template
mustache.parse(fieldErrorsTemplate);
mustache.parse(globalErrorsTemplate);

module.exports.convertErrorObjectIntoHtml = function (rawErrorObject) {
var errorObject = JSON.parse(rawErrorObject.responseText),
Expand All @@ -19,8 +20,8 @@ module.exports.convertErrorObjectIntoHtml = function (rawErrorObject) {
errors: cleanFieldErrors,
globalErrors: errorObject.globalErrors
},
globalErrorHtml = globalErrorsTemplate(cleanErrorObject),
fieldErrorHtml = fieldErrorsTemplate(cleanErrorObject);
globalErrorHtml = mustache.render(globalErrorsTemplate, cleanErrorObject),
fieldErrorHtml = mustache.render(fieldErrorsTemplate, cleanErrorObject);

return globalErrorHtml + fieldErrorHtml;
};
Expand Down
11 changes: 10 additions & 1 deletion opentreemap/treemap/js/src/lib/otmTypeahead.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,13 @@ var getSortFunction = function(sortKeys) {
};

var create = exports.create = function(options) {
var template = mustache.compile($(options.template).html()),
var templateMarkup = $(options.template).html(),
// As of 0.8.0 mustache no longer generates template functions. We
// create an old style template function so that the older version of
// typeahead does not notice the API change.
template = function(data) {
return mustache.render(templateMarkup, data);
},
$input = $(options.input),
$hidden_input = $(options.hidden),
reverse = options.reverse,
Expand Down Expand Up @@ -125,6 +131,9 @@ var create = exports.create = function(options) {
display: 'text'
};

// Parsing speeds up future, repeated usages of the template
mustache.parse(templateMarkup);

if (options.url) {
prefetchEngine = new Bloodhound({
identify: function(datum) {
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
"leaflet.gridlayer.googlemutant ": "~0.4.3",
"leaflet-pip": "~1.0.0",
"lodash": "^4.17.4",
"moment": "~2.2.1",
"mustache": "~0.7.2",
"moment": "~2.11.2",
"mustache": "~2.2.1",
"numeral": "1.5.3",
"ramda": "^0.23.0",
"sanitize-filename": "~1.4.2"
Expand Down

0 comments on commit 48be16c

Please sign in to comment.