-
Notifications
You must be signed in to change notification settings - Fork 1
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
Tower Web templating engine #5
Comments
Hi, i really interested in this project, i really love to learn about parsing, and also currently learning rust, so seeing this project really excite me, but i don't really have any experience in low level and networking stuff, do i need to learn those beforehand to apply for this project? and is there anything that i should know or do? |
@BlinfoldKing Thanks for the interest. I think the details of this project are a bit in flux. The question is now whether Askama can be adapted to fit the requirements or whether a new templating library should be developed from scratch. The requirements of a templating library for tower-web are as follows: Convention over configurationAs much as possible, things should just work "out of the box" using a set of conventions. When using templates from the context of tower-web, there is more available information than using the library standalone. This is a design goal that should influence the other requirements. Templates are compiled at project build time.This is already supported by askama. However, Askama currently requires each template struct to specify the path to the template file. Instead, tower-web's templating should be conventional. For example, lets assume that the "web" code lives in a
Say that in #[derive(Response)]
struct Index { ... } and in #[derive(Response)]
struct Get { ... }
#[derive(Response)]
struct Update { ... } Given this, the crate layout would be:
Template inheritanceAskama already supports this. However, in the spirit of convention over configuration, I would prefer if the parent template does not need to be specified in the child. PerformanceAskama is already pretty fast, but one thing that I would like to experiment is avoiding having to copy any template data around. Currently, I believe Askama renders using I would like to see the ability to render into a By rendering into a Asynchronous renderingThis goal is a bit tricky, but it would be worth exploring. Is it possible to render the template without all the data needed for the full template to be available yet? For example, as a simple example: A user has many blog posts. To render this page, you only need to know if the user ID exists (to decide if the HTTP response should be 404 or not). The template can start rendering before all the blog posts have been loaded. The advantage of doing this is that assets like CSS are included in the head and can start being loaded by the browser. This ties into rendering into a cc/ @djc |
@BlinfoldKing To answer your actual questions :)
There is no networking component to this project. As for "low level", that probably depends on your definition of low level. This project would require byte manipulation and being sensitive to avoiding copying data.
Probably a good idea would be to review Askama and how tower-web currently does templating. |
okey i will check on Askama, and maybe will make some kind of Proof of Concept on my take of the template engine. is there anything that i could contribute to learn on how currently handlebars works on tower? |
@BlinfoldKing one initial step could be to add support for askama in tower-web via a feature flag. So, follow the same strategy as done w/ handlebars. |
@carllerche it's still a little unclear to me how inheritance would be defined by "convention". Also, it's not clear to me whether it's even possible to support the idea that a struct called |
I don't think it would work. That path would get expanded late during compilation, whereas we'd need it in the early phases of compilation (when the procedural macro code is running). |
Well, never say never... the macro could scan the entire source directory 😆 I guess Askama's feature is type full type safety at compile time, but if I had to pick, I would opt for less boilerplate at the expense of more dynamism. |
Your boilerplate is my "explicit is better than implicit". 😛 But I think you're also looking for great performance, which may be somewhat at odds with dynamism? Maybe you should investigate Tera or Ramhorns in more detail and see if they fit better with your ideal design. You did write "Templates are compiled ahead of time using a procedural macro." as one of your very first design points, for which Askama is by the most popular option by far AFAICT. |
sorry for no update in a while, having my mid-term test :/
will it be really slow when there are too many template? and can you give me any refrence to this, i must've miss this But, i do have an idea, a standalone template engine could be implemented explicitly, but the integration with Tower should be seamless, for example we could bind a template by it's route on tower, a /login route should automatically render /login.html and i currently trying to implement askama on tower web, a bit stuck stuck in here too tho, i can't really use the handlebar strategy, handlebar use a registry on the other hand askama using trait. still trying to find a way around |
maybe i'm gonna check on Tera and Ramhorns too |
Did you check the existing integrations that Askama has? For example, see: https://github.com/djc/askama/blob/master/askama/src/lib.rs#L468 |
Tower Web is a web framework built on top of the Tokio stack. It provides a
macro based API. It currently supports HTML templates using an existing
community handlebars library. However, better HTML templating, both in terms of
features and performance, can be achieved by implementing a custom library.
Expected outcomes
Skills
Difficulty level
Medium
The text was updated successfully, but these errors were encountered: