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

Gulp error #714

Closed
Zubrik opened this issue Mar 24, 2016 · 5 comments
Closed

Gulp error #714

Zubrik opened this issue Mar 24, 2016 · 5 comments

Comments

@Zubrik
Copy link

Zubrik commented Mar 24, 2016

I had resolved this problem some time ago: #676

Now when I run my gulp task, I get this error:

Error: (unknown path)
  Error: Cannot use "in" operator to search for "foo" in unexpected types.

So it seems I can't do this anymore:

{% if 'foo' in activePage %}

Yesterday I updated node.js to v4.4.1, I don't know if that could have something to do with the problem.

Thanks.

@carljm
Copy link
Contributor

carljm commented Apr 15, 2016

What type of object is activePage? Can you give a full example for reproduction?

Closing pending further info from OP.

@carljm carljm closed this as completed Apr 15, 2016
@Zubrik
Copy link
Author

Zubrik commented Apr 15, 2016

Hi,

activePage is a variable which contains a string ("foo bar"). I want to check if "foo" exists in that string, so I do

{% set activePage = "foo bar" %}
{% if 'foo' in activePage %}
  <p>foo exists</p>
{% endif %}

which returns the error:

gulp-notify: [Error running Nunjucks] Error: (unknown path)
  Error: Cannot use "in" operator to search for "foo" in unexpected types.

@ricordisamoa
Copy link
Contributor

The source is clear:

exports.inOperator = function (key, arrOrObj) {

It must be an array or an object.

@carljm
Copy link
Contributor

carljm commented Apr 15, 2016

The source is clear, but it's wrong :/ The in operator should work on strings, and it does in Jinja2. And it used to in nunjucks as well, until I merged what was supposed to be just a simple PR to support objects and provide better error messages, but I totally missed the fact that that PR should still have allowed support for strings. That's my fault, I'll get it fixed. Sorry about that @Zubrik.

carljm added a commit that referenced this issue Apr 15, 2016
* 2.x:
  Bump version for 2.5.0 dev.
  Bump version for 2.4.2 release.
  Fix use of 'in' operator with strings. Fixes #714.
  Make a note that setting web:async:true in your config requires use of async render API.
  Fix docs build.
  Docs : Update translations in french
  Merge pull request #721 from jbmoelker/api-docs-prefix-environment
  Merge branch 'ughitsaaron-docs-add-gulp'
  Merge branch 'jbmoelker-patch-1'
  Update changelog.
  Merge pull request #705 from ricordisamoa/mapset
@carljm
Copy link
Contributor

carljm commented Apr 15, 2016

Just released v2.4.2 with the fix for this.

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

3 participants