diff options
author | Amine El Baghdadi <75886237+NoobJsPerson@users.noreply.github.com> | 2021-05-15 17:58:10 +0000 |
---|---|---|
committer | Amine El Baghdadi <75886237+NoobJsPerson@users.noreply.github.com> | 2021-05-15 17:58:10 +0000 |
commit | 99f7ceddcd2ce99a8e2439b3a04e5a3ba236c64a (patch) | |
tree | 0ab5682d3b438d3532c789ac574ad43316a73bd3 /interpolate.js | |
parent | 381a3ab65b507ca18c2ad4c75fb7ad5897bd4dd5 (diff) |
update interpolate.js
Diffstat (limited to 'interpolate.js')
-rw-r--r-- | interpolate.js | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/interpolate.js b/interpolate.js index 36cf2f8..443450e 100644 --- a/interpolate.js +++ b/interpolate.js @@ -3,11 +3,11 @@ const regex = /\${[^{]+}/g; export default function interpolate(template, variables, fallback) {
return template.replace(regex, (match) => {
const path = match.slice(2, -1).trim();
- return getObjPath(path, variables, fallback);
+ return getObjPath(path, variables);
});
}
//get the specified property or nested property of an object
-function getObjPath(path, obj, fallback = '') {
- return path.split('.').reduce((res, key) => res[key] || fallback, obj);
+function getObjPath(path, obj) {
+ return path.split('.').reduce((res, key) => res[key], obj);
}
\ No newline at end of file |