+use std::fs::write;
use std::io::Result;
use std::path::PathBuf;
use crate::template::{find, parse, TemplateContext};
-pub fn generate(_: &PathBuf, template_directory: &PathBuf, _: &PathBuf, context: &TemplateContext) -> Result<()> {
- match find(template_directory, "index.html") {
+const FILENAME: &str = "index.html";
+
+pub fn generate(_: &PathBuf, template_directory: &PathBuf, target: &PathBuf, context: &TemplateContext) -> Result<()> {
+ match find(template_directory, FILENAME) {
Some(template) => {
let parsed_template = parse(&template);
- println!("TOKEN {}", parsed_template.render(context));
+ let rendered_template = parsed_template.render(context);
+ let location = target.join(FILENAME);
+ write(location, rendered_template)?;
},
None => {}
}
fn available_generators() -> Vec<fn(&PathBuf, &PathBuf, &PathBuf, &TemplateContext) -> Result<()>> {
vec![
static_files::generate,
+ // These three are actually the same. Can generalize, don't know how in rust yet.
html::generate,
rss::generate,
txt::generate
+use std::fs::write;
use std::io::Result;
use std::path::PathBuf;
use crate::template::{find, parse, TemplateContext};
-pub fn generate(_: &PathBuf, template_directory: &PathBuf, _: &PathBuf, context: &TemplateContext) -> Result<()> {
- match find(template_directory, "feed.xml") {
+const FILENAME: &str = "feed.xml";
+
+pub fn generate(_: &PathBuf, template_directory: &PathBuf, target: &PathBuf, context: &TemplateContext) -> Result<()> {
+ match find(template_directory, FILENAME) {
Some(template) => {
let parsed_template = parse(&template);
- println!("TOKEN {}", parsed_template.render(context));
+ let rendered_template = parsed_template.render(context);
+ let location = target.join(FILENAME);
+ write(location, rendered_template)?;
},
None => {}
}
+use std::fs::write;
use std::io::Result;
use std::path::PathBuf;
use crate::template::{find, parse, TemplateContext};
-pub fn generate(_: &PathBuf, template_directory: &PathBuf, _: &PathBuf, context: &TemplateContext) -> Result<()> {
- match find(template_directory, "index.txt") {
+const FILENAME: &str = "index.txt";
+
+pub fn generate(_: &PathBuf, template_directory: &PathBuf, target: &PathBuf, context: &TemplateContext) -> Result<()> {
+ match find(template_directory, FILENAME) {
Some(template) => {
let parsed_template = parse(&template);
- println!("TOKEN {}", parsed_template.render(context));
+ let rendered_template = parsed_template.render(context);
+ let location = target.join(FILENAME);
+ write(location, rendered_template)?;
},
None => {}
}