Skip to content

Use template to generate TOC#467

Closed
jacwah wants to merge 12 commits intorust-lang:masterfrom
jacwah:toc
Closed

Use template to generate TOC#467
jacwah wants to merge 12 commits intorust-lang:masterfrom
jacwah:toc

Conversation

@jacwah
Copy link
Copy Markdown
Contributor

@jacwah jacwah commented Oct 8, 2017

Instead of directly writing html from Rust, use a Handlebars template to generate the table of contents. This requires build a separate json object from chapters. To remove the duplicated data, the second commit adapts navigation to use the new toc json object instead, and is an alternative to #465.

Pros:

  • toc is easy to edit and customisable
  • code is more maintainable

Cons:

  • the template generates funky html with lots of whitespace (will look for a solution)
  • complicated template -- some handlebars knowledge required
  • book chapters are processed in two steps (can probably join them to cut down code)

I'm not quite sure how to organise the code. Perhaps toc_json.rs could be merged with helpers/toc.rs. I'm also not sure when to trust the code and use unwrap and when passing along errors is preferred.

#458

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants