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
Handlebars::register_templates_directory
doesn't handle trailing backslash in path correctly on Windows
#388
Comments
Handlebars::register_templates_directory
doesn't handle trailing backslash in path correctlyHandlebars::register_templates_directory
doesn't handle trailing backslash in path correctly on Windows
Thank you for reporting @andrewhickman. I will look into this later |
@andrewhickman since I don't have a window machine, could you please help me to verify if #389 fixed this? |
Yep, that's fixed it, thanks! |
I'm still seeing this with 3.5.1 on Windows 10 (20H2) : let mut tpl = Handlebars::new();
tpl.register_templates_directory(".hbs", "templates/")
.expect("unable to register templates");
println!("Templates:");
for (name, _) in &*tpl.get_templates() {
println!(" - {}", name);
} Assuming I have the following directory tree:
...the code prints:
|
Peering through the source code, I found this: handlebars-rust/src/registry.rs Lines 247 to 251 in e703605
Out of curiosity, why is let prefix_len = dir_path.to_string_lossy().len(); |
@nathan-osman this is to get the relative path of templates. We don't want the relative path to start with separator, so if given path doesn't end with it, we count it into prefix_len. The issue seems to be you are using |
@nathan-osman 3.5.2 should fix this issue |
Minimal repo program:
Run against the following directory structure
With the path
.\test\
, outputs:Note the first letter of the filename has been lost.
The text was updated successfully, but these errors were encountered: