Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add template rendering engine to site #1539

Merged
merged 2 commits into from
Mar 9, 2023
Merged

Add template rendering engine to site #1539

merged 2 commits into from
Mar 9, 2023

Conversation

Kobzol
Copy link
Contributor

@Kobzol Kobzol commented Mar 9, 2023

Use Tera to render HTML templates. This will help us remove duplication (for the top link bar, general page layout, and shared Vue components).

Rendering a template takes about ~10 microseconds in release mode on my laptop. It's pretty much similar time to just reading the raw HTML file directly from disk (what was done before). Actually it could be a bit faster, as Tera now caches the template content in memory. But it shouldn't matter, as the HTML files are aggressively cached anyway using HTTP cache.

Only the help page has been ported to templates so far.

I didn't use e.g. askama, because that inlines the templates into the binary, which would mean that livereloading would require a rebuild of the site binary (which takes seconds, so it's not exactly instant for interactive development).

site/src/server.rs Outdated Show resolved Hide resolved
site/src/templates.rs Show resolved Hide resolved
@rylev
Copy link
Member

rylev commented Mar 9, 2023

Also, shouldn't we be removing the help.html static file?

@Kobzol
Copy link
Contributor Author

Kobzol commented Mar 9, 2023

Also, shouldn't we be removing the help.html static file?

Yes, but the code currently checks that the HTML file exists, and it would need a larger refactoring to change that. And since I want to convert everything to templates anyway in a follow-up PR, I don't think that's worth it.

Use Tera to render HTML templates. Only the help page has been ported to templates so far.
@Kobzol
Copy link
Contributor Author

Kobzol commented Mar 9, 2023

Pff, tera depends on a specific version of chrono that triggers deprecation notices in the current code. I'll fix it in another commit.

@Kobzol Kobzol requested a review from rylev March 9, 2023 11:28
@rylev rylev merged commit 939359a into master Mar 9, 2023
@rylev rylev deleted the site-template branch March 9, 2023 13:14
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.

2 participants