1
Fork 0

Use Tera templates for rustdoc.

Replaces a format!() call in layout::render with a template
expansion. Introduces a `templates` field in SharedContext so parts
of rustdoc can share pre-rendered templates.

This currently builds in a copy of the single template available, like
with static files. However, future work can make this live-loadable with
a perma-unstable flag, to make rustdoc developers' work easier.
This commit is contained in:
Jacob Hoffman-Andrews 2021-06-08 17:19:03 -07:00
parent 50a407200b
commit cd0f93193c
10 changed files with 252 additions and 176 deletions

View file

@ -460,7 +460,14 @@ pub(super) fn write_shared(
})
.collect::<String>()
);
let v = layout::render(&cx.shared.layout, &page, "", content, &cx.shared.style_files);
let v = layout::render(
&cx.shared.templates,
&cx.shared.layout,
&page,
"",
content,
&cx.shared.style_files,
);
cx.shared.fs.write(&dst, v.as_bytes())?;
}
}