diff --git a/book-example/book/index.html b/book-example/book/index.html
index 34e918e4..b4b14455 100644
--- a/book-example/book/index.html
+++ b/book-example/book/index.html
@@ -14,7 +14,7 @@
diff --git a/src/renderer/html_handlebars/hbs_toc_helper.rs b/src/renderer/html_handlebars/hbs_toc_helper.rs
index 0a5dd8da..1400799a 100644
--- a/src/renderer/html_handlebars/hbs_toc_helper.rs
+++ b/src/renderer/html_handlebars/hbs_toc_helper.rs
@@ -18,6 +18,7 @@ impl HelperDef for RenderToc {
// rc.get_path() is current json parent path, you should always use it like this
// param is the key of value you want to display
let chapters = c.navigate(rc.get_path(), "chapters");
+ let current = c.navigate(rc.get_path(), "path").to_string().replace("\"", "");
let path_to_root = c.navigate(rc.get_path(), "path_to_root").to_string().replace("\"", "");
try!(rc.writer.write("
".as_bytes()));
@@ -58,7 +59,14 @@ impl HelperDef for RenderToc {
.to_str().unwrap().as_bytes()
));
- try!(rc.writer.write("\">".as_bytes()));
+ try!(rc.writer.write("\"".as_bytes()));
+
+ println!("[DEBUG] path: {}\n current: {}", path, ¤t);
+ if path == ¤t {
+ try!(rc.writer.write("class=\"active\"".as_bytes()));
+ }
+
+ try!(rc.writer.write(">".as_bytes()));
true
} else {
false
diff --git a/src/renderer/html_handlebars/mod.rs b/src/renderer/html_handlebars/mod.rs
index 30f4cbf7..62b23b07 100644
--- a/src/renderer/html_handlebars/mod.rs
+++ b/src/renderer/html_handlebars/mod.rs
@@ -53,6 +53,10 @@ impl Renderer for HtmlHandlebars {
// Render markdown using the pulldown-cmark crate
content = render_html(&content);
+ // Remove content from previous file and render content for this one
+ data.remove("path");
+ data.insert("path".to_string(), item.path.to_str().unwrap().to_json());
+
// Remove content from previous file and render content for this one
data.remove("content");
data.insert("content".to_string(), content.to_json());
@@ -169,25 +173,6 @@ fn create_file(working_directory: &Path, path: &Path) -> Result
fn make_data(book: BookItems, config: &BookConfig) -> Result, Box> {
- /*
- Function to make the JSon data for the handlebars template:
-
- {
- "language": ...,
- "title": ...
- "chapters": [
- {
- "section": section,
- "chapter": BookItem,
- },
- {
- ...
- },
- ],
- }
-
- */
-
let mut data = BTreeMap::new();
data.insert("language".to_string(), "en".to_json());
data.insert("title".to_string(), config.title.to_json());