This mdbook
backend makes it possible to use
tera templates and expand the capabilities of
your books. It works on top of the default HTML backend.
Run
$ cargo install mdbook-tera-backend
To enable the backend, simply add [output.tera-backend]
to your book.toml
,
and configure the place where youre templates will live. For instance
theme/templates
:
[output.html] # You must still enable the html backend.
[output.tera-backend]
template_dir = "theme/templates"
Create your template files in the same directory as your book.
<!-- ./theme/templates/hello_world.html -->
<div>
Hello world!
</div>
Since the HTML renderer will first render Handlebars templates, we need to tell
it to ignore Tera templates using {{{{raw}}}}
blocks:
{{{{raw}}}}
{% set current_language = ctx.config.book.language %}
<p>Current language: {{ current_language }}</p>
{% include "hello_world.html" %}
{{{{/raw}}}}
Includes names are based on the file name and not the whole file path.
Find out all you can do with Tera templates here.
Please see CHANGELOG for details on the changes in each release.
For questions or comments, please contact Martin Geisler or Alexandre Senges or start a discussion. We would love to hear from you.
This is not an officially supported Google product.