| 498 | } |
| 499 | |
| 500 | fn render_path_with_variables(path: &Path, parser: &Parser, variables: &Object) -> Option<PathBuf> { |
| 501 | let re = regex::Regex::new(r"\{\{[^/]*\}\}").ok()?; |
| 502 | |
| 503 | let path_str = path.to_string_lossy(); |
| 504 | if !re.is_match(&path_str) { |
| 505 | return None; |
| 506 | } |
| 507 | |
| 508 | let template = parser.parse(&path_str).ok()?; |
| 509 | let path_str = template.render(&variables).ok()?; |
| 510 | |
| 511 | Some(PathBuf::from(path_str)) |
| 512 | } |
| 513 | |
| 514 | #[cfg(target_os = "windows")] |
| 515 | fn convert_to_unix_path(path: &Path) -> Option<String> { |