diff --git a/src/renderer/html_handlebars.rs b/src/renderer/html_handlebars.rs
index d1be3696..5ce7c41a 100644
--- a/src/renderer/html_handlebars.rs
+++ b/src/renderer/html_handlebars.rs
@@ -26,14 +26,7 @@ impl Renderer for HtmlHandlebars {
// Register template
try!(handlebars.register_template_string("index", t.to_owned()));
- let mut data = BTreeMap::new();
- let mut chapters: Vec<(String, BookItem)> = vec![];
-
- // Hacky way to prevent move error... Not optimal
- for (section, item) in book.clone() {
- chapters.push((section, item.clone()));
- }
- data.insert("chapters".to_string(), chapters.to_json());
+ let data = try!(make_data(book.clone(), config));
for (_, item) in book {
@@ -119,3 +112,42 @@ fn create_file(working_directory: &Path, path: &Path) -> Result
Ok(file)
}
+
+
+fn make_data(book: BookItems, config: &BookConfig) -> Result> {
+
+ /*
+ Function to make the JSon data for the handlebars template:
+
+ {
+ "language": ???,
+ "chapters": [
+ {
+ "section": section,
+ "chapter": BookItem,
+ },
+ {
+ ...
+ },
+ ],
+ }
+
+ */
+
+ let mut data = BTreeMap::new();
+ data.insert("language".to_string(), "en".to_json());
+
+ let mut chapters = vec![];
+
+ for (section, item) in book {
+ let mut chapter = BTreeMap::new();
+ chapter.insert("section".to_string(), section.to_json());
+ chapter.insert("chapter".to_string(), item.to_json());
+
+ chapters.push(chapter);
+ }
+
+ data.insert("chapters".to_string(), chapters.to_json());
+
+ Ok(data.to_json())
+}
diff --git a/src/theme/book.css b/src/theme/book.css
new file mode 100644
index 00000000..e69de29b
diff --git a/src/theme/book.js b/src/theme/book.js
new file mode 100644
index 00000000..e69de29b
diff --git a/src/theme/index.hbs b/src/theme/index.hbs
index 94d78319..6f5e969e 100644
--- a/src/theme/index.hbs
+++ b/src/theme/index.hbs
@@ -10,7 +10,9 @@
-
+
+ {{ chapters }}
+