Skip to content

Commit 5a0f612

Browse files
Merge pull request #710 from GuillaumeGomez/fix-relative-paths
Fix build determinism and macro path management
2 parents 9eed3ba + 8cec124 commit 5a0f612

File tree

3 files changed

+16
-5
lines changed

3 files changed

+16
-5
lines changed

askama_derive/src/generator.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ mod helpers;
44
mod node;
55

66
use std::borrow::Cow;
7-
use std::env::current_dir;
87
use std::ops::Deref;
98
use std::path::{Path, PathBuf};
109
use std::str;
@@ -179,10 +178,7 @@ impl<'a, 'h> Generator<'a, 'h> {
179178
{
180179
local_file.pop();
181180
if !local_file.is_absolute() {
182-
local_file = current_dir()
183-
.as_deref()
184-
.unwrap_or(Path::new("."))
185-
.join(local_file);
181+
local_file = Path::new(".").join(local_file);
186182
}
187183

188184
self.caller_dir = CallerDir::Valid(clean_path(&local_file));

testing/tests/auxiliary/paths.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
define_template!();

testing/tests/paths.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// This test ensures that template paths work even when created from another file.
2+
#[test]
3+
fn cross_file_paths() {
4+
macro_rules! define_template {
5+
() => {
6+
#[derive(askama::Template)]
7+
#[template(path = "base-decl.txt")]
8+
struct Empty {}
9+
};
10+
}
11+
12+
#[path = "./auxiliary/paths.rs"]
13+
mod a;
14+
}

0 commit comments

Comments
 (0)