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

Replace Handlebars with Tera #688

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

avrong
Copy link

@avrong avrong commented Sep 10, 2020

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" }}">

@avrong avrong requested a review from a team as a code owner September 10, 2020 18:03
@jyn514 jyn514 added dependencies Pull requests that update a dependency file needs review labels Sep 10, 2020
@XAMPPRocky
Copy link
Member

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.

@Manishearth
Copy link
Member

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.

@Manishearth
Copy link
Member

cc @pietroalbini

@avrong
Copy link
Author

avrong commented Sep 12, 2020

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 :)

@XAMPPRocky
Copy link
Member

@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.

@Manishearth
Copy link
Member

Seems okay to me, then.

@Manishearth
Copy link
Member

Oh, this is on the blog repo, I didn't realize :)

@pietroalbini
Copy link
Member

Regardless of Zola, I also vastly prefer working with Tera compared to Handlebars.

@steveklabnik
Copy link
Member

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.

@XAMPPRocky
Copy link
Member

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.

templates/index.html Outdated Show resolved Hide resolved
@avrong
Copy link
Author

avrong commented Nov 10, 2020

Any updates on this? @XAMPPRocky

@XAMPPRocky
Copy link
Member

@avrong Sorry for the delay, and I can't actually merge this anymore, so someone else will have to approve it.

@rylev
Copy link
Member

rylev commented Jun 22, 2022

@avrong sorry we let this slide for so long. Do you have any interest in picking this back up?

@avrong
Copy link
Author

avrong commented Jun 22, 2022

@rylev oh, yeah, will find a time to update this soon

@avrong avrong force-pushed the replace-handlebars-with-tera branch from 862ddd4 to c4e3f49 Compare June 23, 2022 19:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Pull requests that update a dependency file needs review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Replace Handlebars with Tera
8 participants