tera: globwalk does not work with several relative paths
While migrating from a NodeJS-based project to a Rust-based project I found Tera as a template-engine, it was ment to be my introduction project to learn Rust.
As I separate my program and the used templates, I wanted to pass a relative path of some upper folder, but Tera did not find them. After some investigation (and local experiments to change globwalk with glob, which did not work due to unsupported syntax having curly-braces "examples/basic/templates/**/*.{html, xml}"), I found out that it only is an issue for path that point to the current or upper-level folders.
Globwalk does not work for paths starting with./ or ../, there is already an issue open at the other project: https://github.com/Gilnaa/globwalk/issues/28
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 15 (12 by maintainers)
Commits related to this issue
- Error out if glob passed to Tera::new starts with ./ This is because globwalk always returns an empty list in that case, which is likely not what users expect. The corresponding issue in globwalk is... — committed to eguiraud/tera by eguiraud a year ago
- Add test for globs starting with "./" This is a regression test for https://github.com/Keats/tera/issues/574. — committed to eguiraud/tera by eguiraud a year ago
- Always canonicalize glob paths passed to Tera This is to work around an issue in globwalk (https://github.com/Gilnaa/globwalk/issues/28) due to which paths starting with `./` or `../` never match any... — committed to eguiraud/tera by eguiraud a year ago
- Always canonicalize glob paths passed to Tera This is to work around an issue in globwalk (https://github.com/Gilnaa/globwalk/issues/28) due to which paths starting with `./` or `../` never match any... — committed to eguiraud/tera by eguiraud a year ago
- Always canonicalize glob paths passed to Tera (#799) * Add test for globs starting with "./" This is a regression test for https://github.com/Keats/tera/issues/574. * Always canonicalize glob p... — committed to Keats/tera by eguiraud a year ago
At least there, but until then I think it’s worth to get mentioned somewhere, that’s why I opened this issue here. Others might wonder too.
I agree with you @FibreFoX , I just thought there was no consensus on what an actual fix should/would look like, so in the meanwhile I’d rather have Tera report the issue rather than silently having a surprising behavior.
@Keats a PR with what I would propose as an actual fix is at https://github.com/Keats/tera/pull/799 .
Not sure that I am happy with Tera reporting errors with relative paths like in that PR. It does not fix the problem, it just makes more noise. In my opinion it would be a better fix to use something different than globwalk (and yes, breaking changes are okay IMHO if they introduce fixes).
https://xkcd.com/1172/
Hi, due to https://github.com/Gilnaa/globwalk/issues/28 mentioned above passing a path starting with
./or../toTera::newis completely broken. It does not look like https://github.com/Gilnaa/globwalk/issues/28 is going to be fixed any time soon (it’s been 2 years already and there is no consensus on the direction to take).Could Tera maybe side-step the issue by switching to
globorglobset?In my project I’m working around this by taking care to normalize the path I pass to
Tera::new, but if there is a clear direction for a fix I could maybe contribute it.So it should be fixed upstream then