Skip to content

each fails with variable named "officers" #3263

@jabberwock31415

Description

@jabberwock31415

Pug Version: your version number here
3.0.0

Node Version: your version number here
10.21.0

Input JavaScript Values

router.get('/foo', (req, res, next) => {
    res.render('foo', {});
});

Input Pug

- let officers = [{name:'alan'}, {name:'betty'}, {name:'charlie'}];
each dude in officers
  p #{dude.name}

Expected HTML

<p>alan</p>
<p>betty</p>
<p>charlie</p>

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|

3| each dude in officers
----------------------------^
4| p #{dude.name}
5|

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions