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

DEV: Use named parameters for dir-span helper #14195

Merged
merged 2 commits into from Aug 31, 2021
Merged

Conversation

oblakeerickson
Copy link
Member

Follow up to: e50a5c0

In order to improve code clarity this change introduces named parameters
for the dir-span helper. This is specifically for the new htmlSafe
parameter which you can use instead of just passing in a boolean if the
strings you are passing in have already been escaped.

Before: {{dir-span category.description false}}
After: {{dir-span category.description htmlSafe=true}}

Follow up to: e50a5c0

In order to improve code clarity this change introduces named parameters
for the dir-span helper. This is specifically for the new `htmlSafe`
parameter which you can use instead of just passing in a boolean if the
strings you are passing in have already been escaped.

Before: `{{dir-span category.description false}}`
After: `{{dir-span category.description htmlSafe=true}}`
Comment on lines 16 to 22
export default registerUnbound("dir-span", function (str, params) {
let isHtmlSafe = false;
if (params) {
if (params.htmlSafe) {
isHtmlSafe = params.htmlSafe;
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
export default registerUnbound("dir-span", function (str, params) {
let isHtmlSafe = false;
if (params) {
if (params.htmlSafe) {
isHtmlSafe = params.htmlSafe;
}
}
export default registerUnbound("dir-span", function (str, params = {}) {
let isHtmlSafe = false;
if (params.htmlSafe) {
isHtmlSafe = params.htmlSafe;
}

Copy link
Contributor

@tgxworld tgxworld left a comment

Choose a reason for hiding this comment

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

I agree with @eviltrout that this makes the API much clearer. Awesome change and thank you for pushing this through 👍

@tgxworld tgxworld merged commit a2ccf0a into main Aug 31, 2021
@tgxworld tgxworld deleted the dir-span-named-params branch August 31, 2021 05:51
@eviltrout
Copy link
Contributor

Very nice! Thank you @oblakeerickson

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants