Skip to content

Commit

Permalink
Merge pull request #258 from Kijewski/pr-canon-paths
Browse files Browse the repository at this point in the history
Canonicalize include paths before emitting
  • Loading branch information
Kijewski authored Nov 19, 2024
2 parents f86fedd + f595444 commit fb2d4eb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions rinja_derive/src/generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,10 +172,10 @@ impl<'a> Generator<'a> {
Source::Source(_) => path != &*self.input.path,
};
if path_is_valid {
let path = path.to_str().unwrap();
buf.write(format_args!(
"const _: &[rinja::helpers::core::primitive::u8] =\
rinja::helpers::core::include_bytes!({path:#?});",
rinja::helpers::core::include_bytes!({:#?});",
path.canonicalize().as_deref().unwrap_or(path),
));
}
}
Expand Down
6 changes: 3 additions & 3 deletions rinja_derive/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,9 @@ fn check_if_let() {

// In this test we make sure that every used template gets referenced exactly once.
let path = Path::new(env!("CARGO_MANIFEST_DIR")).join("templates");
let path1 = path.join("include1.html");
let path2 = path.join("include2.html");
let path3 = path.join("include3.html");
let path1 = path.join("include1.html").canonicalize().unwrap();
let path2 = path.join("include2.html").canonicalize().unwrap();
let path3 = path.join("include3.html").canonicalize().unwrap();
compare(
r#"{% include "include1.html" %}"#,
&format!(
Expand Down

0 comments on commit fb2d4eb

Please sign in to comment.