diff options
| author | WriterV2 <primary-v2@protonmail.com> | 2022-08-23 19:24:17 +0200 |
|---|---|---|
| committer | WriterV2 <primary-v2@protonmail.com> | 2022-08-23 19:24:17 +0200 |
| commit | 746c348f739a8d5f26d4cd76ed72646a338271c4 (patch) | |
| tree | 818b38c82171bd48529e05ee98da15aab84aff55 /src/works | |
| parent | f08b050c240f10b29d5c8af5e80f042c115cd49b (diff) | |
Modify function to create tera context for stories
Diffstat (limited to 'src/works')
| -rw-r--r-- | src/works/mod.rs | 2 | ||||
| -rw-r--r-- | src/works/stories.rs | 8 |
2 files changed, 4 insertions, 6 deletions
diff --git a/src/works/mod.rs b/src/works/mod.rs index f399fdd..3dfd4a2 100644 --- a/src/works/mod.rs +++ b/src/works/mod.rs @@ -10,5 +10,5 @@ pub trait Works: for<'a> Deserialize<'a> { } } - fn create_tera_context(&self) -> Vec<tera::Context>; + fn create_tera_context(&self) -> tera::Context; } diff --git a/src/works/stories.rs b/src/works/stories.rs index 5d96ed8..450f3bc 100644 --- a/src/works/stories.rs +++ b/src/works/stories.rs @@ -14,12 +14,10 @@ pub struct Story { } impl super::Works for Stories { - fn create_tera_context(&self) -> Vec<tera::Context> { - let mut context = Vec::new(); + fn create_tera_context(&self) -> tera::Context { + let mut context = tera::Context::new(); for story in self.0.iter() { - context.push( - tera::Context::from_serialize(&story).expect("Trying to serialize to tera context"), - ); + context.insert(format!("story-{}", story.id), &story); } context } |
