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

template not found error in Windows #42

Closed
navedmirCM opened this issue Jan 24, 2020 · 12 comments · Fixed by #43
Closed

template not found error in Windows #42

navedmirCM opened this issue Jan 24, 2020 · 12 comments · Fixed by #43
Labels
bug Something isn't working

Comments

@navedmirCM
Copy link

navedmirCM commented Jan 24, 2020

I am trying to import a nunjuck template(html file). It is imported correctly but the template path inside the object is messed up, half is windows stlye and half is linux.

browser Console error

list.js?986a:17 Error: template not found: \products\_productLoader.html at createTemplate (nunjucks-slim.js?cede:1497) at next (nunjucks-slim.js?cede:368) at handle (nunjucks-slim.js?cede:1536) at eval (nunjucks-slim.js?cede:1546) at next (nunjucks-slim.js?cede:366)

The bundle object :-
logging the object

My import statement :-
const _productLoaderHtml = require('../../../views/nunjucks/products/_productLoader.html')

@ogonkov
Copy link
Owner

ogonkov commented Jan 25, 2020

Can you make a repo to reproduce an error?

@navedmir
Copy link

So , I tested again and the issue occurs only in windows. There is a template not found error on windows because the template name doesn't match with nunjucks.render(template).
It is because of linux vs windows path issue.
Eg :-

__nunjucks_module_dependencies__.templates["products/_productLoader.html"] nunjucks.render("products\\_productLoader.html")

For ref :-
mozilla/nunjucks#146

@navedmir
Copy link

navedmir commented Jan 28, 2020

Suggested change in file loader.js , line 50

const resourcePathString = JSON.stringify(resourcePathImport.replace(/\\/g, '/'));

I am using the same code, which is used in nunjucks to modify the template name

https://github.com/mozilla/nunjucks/blob/master/nunjucks/src/precompile.js#L113

@ogonkov
Copy link
Owner

ogonkov commented Jan 28, 2020

I think I need to make sure that path is not changed after precompilation. I will add tests and fix it on this week.

@ogonkov
Copy link
Owner

ogonkov commented Jan 29, 2020

For history, all tests failed on Windows environment https://travis-ci.org/ogonkov/nunjucks-loader/builds/643552671

@ogonkov
Copy link
Owner

ogonkov commented Jan 29, 2020

Seems like it is expected behaviour (mozilla/nunjucks#761 & mozilla/nunjucks#825), and i should force unix-style path in loader too.

@ogonkov ogonkov added the bug Something isn't working label Jan 31, 2020
@ogonkov
Copy link
Owner

ogonkov commented Jan 31, 2020

@navedmir please test latest master for your project, does it work for you?

You can change version to latest git like

{
  "devDependencies": {
    "simple-nunjucks-loader": "ogonkov/nunjucks-loader#afa716d"
  }
}

@navedmirCM
Copy link
Author

Is there a plan to release this anytime soon?
Referencing the commit "ogonkov/nunjucks-loader#afa716d" doesn't work because there is no lib directory as the project is not build.

@ogonkov
Copy link
Owner

ogonkov commented Feb 13, 2020

@navedmirCM sorry, i got your problem. Will release it soon.

@ogonkov
Copy link
Owner

ogonkov commented Feb 13, 2020

Released in v1.0.1

@ogonkov
Copy link
Owner

ogonkov commented Feb 13, 2020

@navedmirCM @navedmir please share your experience with latest version

@navedmirCM
Copy link
Author

It works on windows now, I will test it more with other features.
Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants