Skip to content
This repository has been archived by the owner on Oct 11, 2020. It is now read-only.

Templating library integrations #3

Open
1 of 4 tasks
kazimuth opened this issue May 7, 2019 · 2 comments
Open
1 of 4 tasks

Templating library integrations #3

kazimuth opened this issue May 7, 2019 · 2 comments
Labels
good first issue Good for newcomers integrations Integrations with other libraries

Comments

@kazimuth
Copy link
Owner

kazimuth commented May 7, 2019

  • handlebars
  • tera
  • askama
  • maud

http://www.arewewebyet.org/topics/templating/

@kazimuth kazimuth added enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed integrations Integrations with other libraries and removed enhancement New feature or request help wanted Extra attention is needed labels May 7, 2019
@godofdream
Copy link

If you point me how you intended to include the localization into e.g. askama I may be of help.

@kazimuth
Copy link
Owner Author

kazimuth commented May 8, 2019

That'd be great!

In general each templating library has a different method for integrating custom filters / external functions / whatever. Where possible, we should just supply implementations for those in this library, instead of modifying external libraries. e.g. in tera there's various register_xyz implementations; we could provide one of those in this crate, behind a feature flag.

In askama's case though, I think we need to at least add some sort of support for passing kwargs to templates; currently they only take ordered arguments. It might also be possible to just pass all the members of an askama template struct through to fluent. There's a design space there, explore it at your leisure.

The code in my old PR could give you a hint at where to start. https://github.com/djc/askama/pull/211; it's a little messy and bitrotted, but I added a parser for localize expressions to askama_derive/src/parser.rs, support for embedding a Localize impl in an askama template in askama_derive/src/input.rs, and support for generating calls to that impl in askama_derive/src/generator.rs. The rest of the code in that PR is in this crate.

Keep in mind this project isn't officially "released" yet and i'm going to do a little more iteration on the core design this week (like changing Localize::localize to take an &mut io::Write instead of returning a String).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
good first issue Good for newcomers integrations Integrations with other libraries
Projects
None yet
Development

No branches or pull requests

2 participants