-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- added reporters to karma config - refactored santize functions into utils module - narrowed scope of coverage testing to non-d3, non-leaflet, non-pubsub code - corrected imports of santize functions - refactored render function to use resolvePath - removed resolveObjPath fn from templates module - removed topologyTools module - added some jsdoc inlinedocs for utils module - refactored util fn name from getUrlSearchParams to getUrlQueryParams
- Loading branch information
1 parent
04963b9
commit 46a1b5b
Showing
8 changed files
with
400 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,10 @@ | ||
const TEMPLATE_REGEX = /\${[^{]+}/g; | ||
|
||
// copied from Matt Browne's answer https://stackoverflow.com/questions/29182244/convert-a-string-to-a-template-string | ||
// functions renamed slightly for readability | ||
import { resolvePath } from './utils.js'; | ||
|
||
//get the specified property or nested property of an object | ||
function resolveObjPath(path, obj, fallback = '') { | ||
return path.split('.').reduce((res, key) => res[key] || fallback, obj); | ||
} | ||
const TEMPLATE_REGEX = /\${[^{]+}/g; | ||
|
||
export function render(template, variables, fallback) { | ||
return template.replace(TEMPLATE_REGEX, (match) => { | ||
const path = match.slice(2, -1).trim(); | ||
return resolveObjPath(path, variables, fallback); | ||
return resolvePath(path, variables, fallback); | ||
}); | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.