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

Inline conditional math not working as expected #3411

Open
jstncmorgan opened this issue Apr 17, 2023 · 0 comments
Open

Inline conditional math not working as expected #3411

jstncmorgan opened this issue Apr 17, 2023 · 0 comments

Comments

@jstncmorgan
Copy link

jstncmorgan commented Apr 17, 2023

Pug Version: 3.0.2

Node Version: 16.15.0

Pug is being rendered via express
The following two blocks of pug code give different results:

each page in paginatorPages
    li(class="page-item" class={"d-none d-sm-flex": page < currentPage - 1 || page > currentPage + 0})
each page in paginatorPages
    li(class="page-item" class={"d-none d-sm-flex": page < currentPage - 1 || page > currentPage})

The only difference is the + 0 near the end of the second line. My actual use case here is that I would like to check page > currentPage + 1, but through experimentation, I discovered that any addition operation in the back half of the second equation results in strange behavior. Resultant HTML is as follows where currentPage == 3 and paginatorPages == [1, 2, 3, 4, 5]:

<li class="page-item d-none d-sm-flex"></li>
<li class="page-item"></li>
<li class="page-item"></li>
<li class="page-item"></li>
<li class="page-item"></li>
<li class="page-item d-none d-sm-flex"></li>
<li class="page-item"></li>
<li class="page-item"></li>
<li class="page-item d-none d-sm-flex"></li>
<li class="page-item d-none d-sm-flex"></li>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant