Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: STRF-9707 Improve money helper to support input params #164

Merged
merged 1 commit into from
Mar 22, 2022
Merged

feat: STRF-9707 Improve money helper to support input params #164

merged 1 commit into from
Mar 22, 2022

Conversation

jairo-bc
Copy link
Contributor

What? Why?

Improved money helper to support input params according to the docs

How was it tested?

npm test, e2e


cc @bigcommerce/storefront-team

@jairo-bc jairo-bc requested review from bookernath and a team March 21, 2022 16:59
@@ -56,6 +56,7 @@ describe('strReplace helper', function() {

it('should throw an exception if the parameters have an invalid type', function(done) {
renderString('{{strReplace object "none" "Bob"}}').catch(e => {
// console.log(e);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need this comment here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, I thought I removed it :)

@jairo-bc jairo-bc requested a review from bc-max March 21, 2022 17:19
if (!_.isNumber(value)) {
return '';
// remove options hash object
args.pop();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we able to exclude this by doing something like return function(options, ...args) to pull out the first param as "options" and just use the remaining in args to avoid this step?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not really, cause I'm removing the last parameter, rather then the first one.
So it should be like return function(...args, options), but this kind of syntax is not supported 😒

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it necessary to remove this at all, since we're just accessing the other elements by args[0] etc, wont those indexes be the same regardless if the last element in present?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jmwiese the thing is that number of arguments may vary. Just to be sure, that hash object (that has handlebars utility functions) was removed, I'm using a pop(). We are also using same approach in other helpers, to actually read that hash object by assigning it to a variable.

@jairo-bc jairo-bc merged commit 86fdbda into bigcommerce:master Mar 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants