-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
each fails with variable named "officers" #3263
each fails with variable named "officers" #3263
Comments
Thanks for reporting this. I will look into fixing it, as it is an un-intentional regression. In the mean time, if you update to the newer syntax, that should work: - let officers = [{name:'alan'}, {name:'betty'}, {name:'charlie'}];
each dude of officers
p #{dude.name} |
I get the same error with the new syntax:
|
improve capture group regex for `each` statements using a greedy match. fixes pugjs#3263
Proposed a Pull-Request. Rename your variable to start with something other than |
add test cases covering pugjs#3275 and pugjs#3263
Variable named |
The variable must not start with any of the keywords (like |
Half year past, breaking issue does not solved |
@Delagen Seems just fine to me. Did you try? - let officers = [{name:'alan'}, {name:'betty'}, {name:'charlie'}];
each officer in officers
officer #{officer.name} |
Try to use via locals as express template engine |
This run in the browser, no express involved, still good. JSON: {
"user": {
"name": "TrasherDK",
"options": {"A": "Alpha","B": "Bravo","C": "Charlie","D": "Delta"}
},
"officegirls": [
{"name":"Alice"},
{"name":"Beatrice"},
{"name":"Cindy"}
], PUG: - let officers = [{name:'alan'}, {name:'betty'}, {name:'charlie'}];
each officer in officers
officer #{officer.name}
each officegirl in officegirls
officer #{officegirl.name}
#select Select something
select
each option in user.options
option(option.id) #{option} |
I think this would also fail if your variable would start with the characters "in". #3274 fixes this behaviour for the /edit: I tested the regex for the |
The
|
I was still hitting issue pugjs#3263 when using "in" instead of "of" (which caused other odd problems). The regex was looking for * (0+) spaces instead of + (at least one) space. Using + instead prevents the regex from catching "in ofxxxxx".
I have a same problem extends dashboardLayout
block content
h4.grey-text.center-align Offerwalls
.row.justify-content-center.justify-content-md-start(style="margin-top: 3rem;")
each offerwall in offerwalls
.col.card.shadow.border-0.m-1(style='min-width: 15rem;max-width: 18rem;')
img.card-img-top(src=`${offerwall.bannerImgUrl || '/img/noimage.png'}` style='height:15rem;object-fit: cover;')
.card-body
h6.card-title.font-weight-bold #{offerwall.title}
br
p.text-grey #{offerwall.description}
.text-center
a.btn.btn-primary(href=`/dashboard/offerwall/${offerwall.id}`) Show #{offerwall.title} error:
|
Hi, I faced this problem when I had a variable named |
This was extremely unexpected. I spent the whole evening yesterday trying to figure out what was going on. |
I also spent a few hours then. But is it still relevant? |
I was still hitting issue pugjs#3263 when using "in" instead of "of" (which caused other odd problems). The regex was looking for * (0+) spaces instead of + (at least one) space. Using + instead prevents the regex from catching "in ofxxxxx".
Pug Version: your version number here
3.0.0
Node Version: your version number here
10.21.0
Input JavaScript Values
Input Pug
Expected HTML
Actual HTML
none--pug errors out
Additional Comments
I get an error thrown from pug:
Error: /home/NPL/www/express-web/views/directory.pug:3:22
1| - let officers = [{name:'alan'}, {name:'betty'}, {name:'charlie'}];
2|
The value variable for each must either be a valid identifier (e.g.
item
) or a pair of identifiers in square brackets (e.g.[key, value]
).If I change the name of the variable from "officers" to something else ("ooficers" for example) the script works
The text was updated successfully, but these errors were encountered: