]>
Commit | Line | Data |
---|---|---|
b17907fa | 1 | use crate::template::{find, parse, Context}; |
60307a9a | 2 | use std::fs::write; |
50f53dc4 | 3 | use std::io::{Error, ErrorKind::Other, Result}; |
b17907fa | 4 | use std::path::Path; |
29982470 | 5 | |
60307a9a RBR |
6 | const FILENAME: &str = "feed.xml"; |
7 | ||
d7fef30a | 8 | pub fn generate( |
b17907fa RBR |
9 | _: &Path, |
10 | template_directory: &Path, | |
11 | target: &Path, | |
12 | context: &Context, | |
d7fef30a | 13 | ) -> Result<()> { |
b17907fa RBR |
14 | if let Some(template) = find(template_directory, FILENAME) { |
15 | let parsed_template = | |
16 | parse(&template).ok_or_else(|| Error::new(Other, "Unable to parse RSS template"))?; | |
17 | let rendered_template = parsed_template.render(context)?; | |
18 | let location = target.join(FILENAME); | |
19 | write(location, rendered_template)?; | |
f6a545b0 | 20 | } |
29982470 RBR |
21 | Ok(()) |
22 | } |