Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Use mustache to process connection template (#1110)
  • Loading branch information
rickbergfalk committed Mar 14, 2022
1 parent 2e15670 commit 3f92be3
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
11 changes: 7 additions & 4 deletions server/lib/render-connection.js
@@ -1,4 +1,9 @@
const _ = require('lodash');
const mustache = require('mustache');

// Disable HTML escaping. We're not using it for HTML
mustache.escape = function (text) {
return text;
};

/**
* Iterates over connection object, replacing any template strings with values from user
Expand All @@ -19,9 +24,7 @@ function renderConnection(connection, user) {
} else {
const value = connection[key];
if (typeof value === 'string') {
_.templateSettings.interpolate = /{{([\s\S]+?)}}/g;
const compiled = _.template(value);
replaced[key] = compiled({ user });
replaced[key] = mustache.render(value, { user });
} else {
replaced[key] = value;
}
Expand Down
5 changes: 5 additions & 0 deletions server/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions server/package.json
Expand Up @@ -69,6 +69,7 @@
"mkdirp": "^1.0.4",
"moment": "^2.29.1",
"mssql": "^8.0.2",
"mustache": "^4.2.0",
"mysql": "^2.18.1",
"mysql2": "^2.3.3",
"node-crate": "^2.0.6",
Expand Down

0 comments on commit 3f92be3

Please sign in to comment.