aboutsummaryrefslogtreecommitdiffhomepage
path: root/interpolate.js
diff options
context:
space:
mode:
authorAmine El Baghdadi <75886237+NoobJsPerson@users.noreply.github.com> 2021-05-15 17:58:10 +0000
committerAmine El Baghdadi <75886237+NoobJsPerson@users.noreply.github.com> 2021-05-15 17:58:10 +0000
commit99f7ceddcd2ce99a8e2439b3a04e5a3ba236c64a (patch)
tree0ab5682d3b438d3532c789ac574ad43316a73bd3 /interpolate.js
parent381a3ab65b507ca18c2ad4c75fb7ad5897bd4dd5 (diff)
update interpolate.js
Diffstat (limited to 'interpolate.js')
-rw-r--r--interpolate.js6
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