bottender-compose
Advanced tools
Comparing version 0.12.2 to 0.12.3
@@ -0,1 +1,17 @@ | ||
# 0.12.3 / 2018-09-06 | ||
- [improve] improve warning when compiling template #82 | ||
##### Before: | ||
``` | ||
Properties accessors in template is invalid -- expected return a string but got: object | ||
``` | ||
##### After: | ||
``` | ||
Properties accessors (context.session.user) in template is invalid -- expected return a non-empty string but got: object | ||
``` | ||
# 0.12.2 / 2018-09-05 | ||
@@ -2,0 +18,0 @@ |
@@ -102,9 +102,9 @@ "use strict"; | ||
expectTemplate('Hi, {{context.session.user.first_name}}'); | ||
expect(warning).toBeCalledWith(true, 'Properties accessors in template is invalid -- expected return a string but got: string'); | ||
expect(warning).toBeCalledWith(true, 'Properties accessors (context.session.user.first_name) in template is invalid -- expected return a non-empty string but got: string'); | ||
}); | ||
it('should show warning when the result of properties accessors is not a string', () => { | ||
expectTemplate('Hi, {{context.session.user}}').toBe('Hi, [object Object]'); | ||
expect(warning).toBeCalledWith(false, 'Properties accessors in template is invalid -- expected return a string but got: object'); | ||
expect(warning).toBeCalledWith(false, 'Properties accessors (context.session.user) in template is invalid -- expected return a non-empty string but got: object'); | ||
}); | ||
}); | ||
}); |
@@ -32,12 +32,14 @@ "use strict"; | ||
let value; | ||
let properties; | ||
if (firstWhitelistKey === 'param') { | ||
value = get(param, otherResults[0].slice(1), ''); | ||
properties = otherResults[0].slice(1); | ||
value = get(param, properties); | ||
} else { | ||
const properties = `${contextKeyPrefixResolveMap[firstWhitelistKey]}${otherResults[0].slice(1)}`; | ||
value = get(context, properties, ''); | ||
properties = `${contextKeyPrefixResolveMap[firstWhitelistKey]}${otherResults[0].slice(1)}`; | ||
value = get(context, properties); | ||
} | ||
warning(typeof value === 'string', `Properties accessors in template is invalid -- expected return a string but got: ${typeof value}`); | ||
compiledResult = replace(compiledResult, targetString, value); | ||
warning(value && typeof value === 'string', `Properties accessors (${firstWhitelistKey}.${properties}) in template is invalid -- expected return a non-empty string but got: ${typeof value}`); | ||
compiledResult = replace(compiledResult, targetString, value || ''); | ||
templateRegExp.lastIndex = 0; | ||
@@ -44,0 +46,0 @@ } |
@@ -9,3 +9,3 @@ { | ||
}, | ||
"version": "0.12.2", | ||
"version": "0.12.3", | ||
"main": "lib/index", | ||
@@ -12,0 +12,0 @@ "files": [ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
106630
2416