Skip to content

Commit

Permalink
Use bult-in formatting of Rust instead of template library
Browse files Browse the repository at this point in the history
  • Loading branch information
amatho committed May 27, 2018
1 parent 0031ea4 commit 3f2cb70
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 329 deletions.
257 changes: 0 additions & 257 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,3 @@ version = "0.1.0"
authors = ["Amandus Thorsrud <[email protected]>"]

[dependencies]
handlebars = "0.32.1"
serde = "1.0.47"
serde_derive = "1.0.47"
serde_json = "1.0.17"
15 changes: 3 additions & 12 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,23 +1,15 @@
extern crate handlebars;
#[macro_use]
extern crate serde_derive;

extern crate serde;

mod template;

use std::fs;
use std::path;
use std::env;

#[derive(Serialize)]
struct FileData {
file_type: String,
file_name: String,
}

#[derive(Serialize)]
struct Data {
pub struct Data {
files: Vec<FileData>,
dir: String,
}
Expand Down Expand Up @@ -97,8 +89,7 @@ fn should_ignore(path: &path::PathBuf) -> bool {
}

fn write_index(data: Data, working_dir: String) {
let handlebars = handlebars::Handlebars::new();
let temp = handlebars.render_template(template::TEMPLATE, &data).expect("Could not render template.");
let contents = template::generate(data);
let write_path = path::Path::new(&working_dir).join("index.html");
fs::write(write_path, temp).expect("Could not write index.html.");
fs::write(write_path, contents).expect("Could not write index.html.");
}
Loading

0 comments on commit 3f2cb70

Please sign in to comment.