Find the on-disk path of a template, if it exists as a file. Returns None for embedded-only templates.
(
name: &str,
project_root: Option<&Path>,
tsk_env: &TskEnv,
)
| 91 | /// Find the on-disk path of a template, if it exists as a file. |
| 92 | /// Returns None for embedded-only templates. |
| 93 | pub fn find_template_path( |
| 94 | name: &str, |
| 95 | project_root: Option<&Path>, |
| 96 | tsk_env: &TskEnv, |
| 97 | ) -> Option<std::path::PathBuf> { |
| 98 | let filename = format!("{name}.md"); |
| 99 | |
| 100 | // Check project level first |
| 101 | if let Some(root) = project_root { |
| 102 | let project_path = root.join(".tsk").join("templates").join(&filename); |
| 103 | if project_path.exists() { |
| 104 | return Some(project_path); |
| 105 | } |
| 106 | } |
| 107 | |
| 108 | // Check user level |
| 109 | let user_path = tsk_env.config_dir().join("templates").join(&filename); |
| 110 | if user_path.exists() { |
| 111 | return Some(user_path); |
| 112 | } |
| 113 | |
| 114 | None |
| 115 | } |
| 116 | |
| 117 | /// List all available templates from project, user, and embedded sources. |
| 118 | pub fn list_all_templates(project_root: Option<&Path>, tsk_env: &TskEnv) -> Vec<String> { |