Skip to content
New issue

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

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

Already on GitHub? # to your account

Wrong argument ordering in default function #3150

Closed
2 tasks done
filvuk opened this issue Oct 6, 2024 · 0 comments
Closed
2 tasks done

Wrong argument ordering in default function #3150

filvuk opened this issue Oct 6, 2024 · 0 comments

Comments

@filvuk
Copy link
Contributor

filvuk commented Oct 6, 2024

Preliminary Checks

Description

Line 20 of modules/blox-bootstrap/layouts/partials/blocks/portfolio.html reads:

{{ $filter_default := default (int $block.content.default_button_index) 0 }}

Shouldn't this rather be default 0 (int $block.content.default_button_index)?
According to the Hugo docs default "[r]eturns the second argument if set, else the first argument". Also:

When the second argument is the boolean false value, the default function returns false. All other falsy values are considered unset.
The falsy values are false, 0, any nil pointer or interface value, any array, slice, map, or string of length zero, and zero time.Time values.

So as it's currently written, default always returns int $block.content.default_button_index. This doesn't seem intended to me.

Reproduction Link

{{ $filter_default := default (int $block.content.default_button_index) 0 }}

Steps to Reproduce

To be fair, I didn't try to reproduce locally, since this seems clear-cut.

Expected Result

If $block.content.default_button_index is unset, use 0, otherwise use the set value.

Actual Result

$block.content.default_button_index is always used

What Hugo Module versions does your site use?

Same modules from research-group theme

What operating system(s) are you seeing the problem on?

Windows, macOS, Android, iOS, Linux

What browser(s) are you seeing the problem on?

Chrome, Safari, Firefox, Microsoft Edge, Other

Which Hugo Blox template are you using?

Research Group

What version of Hugo are you using?

0.125.7

@filvuk filvuk changed the title Bug in portfolio block Wrong argument ordering in default function Oct 6, 2024
@gcushen gcushen added the bug label Oct 12, 2024
@gcushen gcushen closed this as completed Oct 13, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

2 participants