diff options
author | Daniel Silverstone <dsilvers@digital-scurf.org> | 2021-01-09 16:15:35 +0000 |
---|---|---|
committer | Daniel Silverstone <dsilvers@digital-scurf.org> | 2021-01-10 09:49:25 +0000 |
commit | fcdbd77cc2b909b8a1d0fc8d2e6343bbc278470c (patch) | |
tree | 05420ead169a05ae3a2b0a7c4564e230596f1fb0 /src/codegen.rs | |
parent | e9b941e5218e5e4293bb915b13f831baba246a89 (diff) | |
download | subplot-fcdbd77cc2b909b8a1d0fc8d2e6343bbc278470c.tar.gz |
resource: Switch from 'templates' to 'share'
In a general sense, we will want to have more than just template
files as resources. This shifts from the concept that the only
thing resource-wise that subplot has is templates, to a more general
shared resources concept without a default path beyond CWD.
Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
Diffstat (limited to 'src/codegen.rs')
-rw-r--r-- | src/codegen.rs | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/codegen.rs b/src/codegen.rs index 063f8a2..93d1c75 100644 --- a/src/codegen.rs +++ b/src/codegen.rs @@ -9,19 +9,20 @@ use base64::encode; use serde::Serialize; use tera::{Context, Tera, Value}; -use anyhow::Result; +use anyhow::{Context as AnyhowContext, Result}; /// Return the requested template specification. -pub fn template_spec(templates: &Path, doc: &Document) -> Result<TemplateSpec> { +pub fn template_spec(doc: &Document) -> Result<TemplateSpec> { let template = doc .meta() .template_name() .ok_or(SubplotError::MissingTemplate)?; - let mut filename = templates.to_path_buf(); + let mut filename = PathBuf::from("templates"); filename.push(Path::new(template)); filename.push(Path::new("template.yaml")); - Ok(TemplateSpec::from_file(&filename)?) + Ok(TemplateSpec::from_file(&filename) + .with_context(|| format!("Failed to read template file: {}", filename.display()))?) } /// Generate a test program from a document, using a template spec. |