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

Error in 1.14.0: "file.indexOf is not a function" #682

Open
evanmwillhite opened this issue Nov 21, 2019 · 5 comments
Open

Error in 1.14.0: "file.indexOf is not a function" #682

evanmwillhite opened this issue Nov 21, 2019 · 5 comments

Comments

@evanmwillhite
Copy link

We are running into an error with the latest release that is occurring with situations containing some/all of the following characteristics:

  1. Nested includes
  2. Using a namespace
  3. Inside a macro

I'm not actually sure which of those are causing it, but I wondered if this might ring a bell. If you'd like to test and verify, I have a branch here. To see it, run yarn develop and then go to this page.

This is a little bit from the error log:

Uncaught TypeError: file.indexOf is not a function
    at Object.Twig.path.parsePath (twig.js:7578)

which points to this line:

if (file.indexOf(k) === -1) {

Let me know if I can provide any more feedback, and thanks for your work on this project!

@liberat0r
Copy link

+1

@liberat0r
Copy link

I was able to locate this issue in line https://github.com/twigjs/twig.js/blob/master/src/twig.core.js#L1349
Twig.path.parsePath is being called with template objects as params instead of the expected strings.

Issue seems to be isolated when using namespaces, example:

     const template = twig({
          data: data,
          allowInlineIncludes: true,
          namespaces: {'myTheme': path.resolve(__dirname, 'theme')},
        });

@mralexho
Copy link

mralexho commented Oct 16, 2020

I also ran into this issue with nested includes. Confirming this seems to be isolated to namespaces.

I'm running v1.15.2.

@ccjjmartin
Copy link

For anyone running into this issue you might want to check to see if this PR (fixes it, it fixed a related issue for me): #784

@willrowe
Copy link
Collaborator

Is someone able to provide a simple example with links to it working in TwigPHP via Twigfiddle and not working in twig.js using this template? I looked at the referenced PR, but there are no test provided with it, so I want to make sure the actual issue is being resolved there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants