Skip to content

fix capture groups for "each" statements#3274

Merged
ForbesLindesay merged 2 commits intopugjs:masterfrom
error418:fix/each
Feb 28, 2021
Merged

fix capture groups for "each" statements#3274
ForbesLindesay merged 2 commits intopugjs:masterfrom
error418:fix/each

Conversation

@error418
Copy link
Copy Markdown
Contributor

@error418 error418 commented Jul 3, 2020

Variables starting with of cause the regex to "drift" on capture groups

Example

each item of offers
  i= item

This causes

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]`).

Cause

The non-greedy (.*) matches the of of the variable for the of statement. This causes matching group misalignment, which leads to the displayed error.

Workaround

Rename your variable to something not starting with of 😊


fixes #3263
fixes #3275

improve capture group regex for `each` statements using a greedy match.

fixes pugjs#3263
@rollingversions
Copy link
Copy Markdown

rollingversions bot commented Jul 3, 2020

pug-lexer (5.0.0 → 5.0.1)

Bug Fixes

  • Variables starting with keywords cause the regex to "drift" on capture groups, causing errors

Packages With No Changes

The following packages have no user facing changes, so won't be released:

  • pug
  • pug-attrs
  • pug-code-gen
  • pug-error
  • pug-filters
  • pug-linker
  • pug-load
  • pug-parser
  • pug-runtime
  • pug-strip-comments
  • pug-walk

Edit changelogs

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

Successfully merging this pull request may close these issues.

Passing ["foo of bar"] to each causing a syntax error each fails with variable named "officers"

2 participants