blog.rust-lang.org
blog.rust-lang.org copied to clipboard
Replace Handlebars with Tera
Closes #599
I replaced the handlebars
crate with tera
, adapted the Generator
, and its render_template
method, converted the month_name
filter and the templates.
I'm not sure that all I've done is correct, so happy to make it better. The thing I'm not confident about is should the string concatenation be preferred in HTML args inside the templates:
// injecting
<link href="https://blog.rust-lang.org/{{ blog.prefix }}feed.xml">
// concatenation
<link href="{{ "https://blog.rust-lang.org/" ~ blog.prefix ~ "feed.xml" }}">
Thank you for your PR! I’ll test this over the weekend, but it looks good to me. I think the former style you used in the PR is fine for now.
Given that we're holding off on Zolaification, is there a strong reason to switch to Tera? If it simplifies things I'm all for it though.
cc @pietroalbini
Personally I prefer Tera templates because of their explicitness in template tags. Maybe it would also make them easier to understand for the new people and those who had experience with Jinja2/Django templates :)
@Manishearth Yes, I think we want Tera for templating, it's much more powerful in ways that we care about. (For example; you can easily generate HTML from remote urls such as team data), and more DRY (you can set variables in the template, functions are just rust functions).
I also personally prefer the syntax, I find things like blocks are harder to get wrong in tera than handlebars' sigil heavy syntax. I know docs.rs switched to using it awhile ago.
None of this is in the current PR of course, it's a pretty straight 1-to-1 port.
Seems okay to me, then.
Oh, this is on the blog repo, I didn't realize :)
Regardless of Zola, I also vastly prefer working with Tera compared to Handlebars.
I really prefer how handlebars is more broadly known than terra, but at the same time, I don't do a ton of work in this codebase, so I don't think that should be a blocker.
FWIW Tera's syntax is derived from templating languages like Jinja (Django/Python) and Twig (Symphony/PHP), which are incredibly popular in their respective languages. So I think whether one is more broad than the other really depends on your previous web experience and what you were already using before.
Any updates on this? @XAMPPRocky
@avrong Sorry for the delay, and I can't actually merge this anymore, so someone else will have to approve it.
@avrong sorry we let this slide for so long. Do you have any interest in picking this back up?
@rylev oh, yeah, will find a time to update this soon