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

migrate all templates to jinja2 #170

Closed
mwasilew opened this issue Jan 10, 2018 · 4 comments
Closed

migrate all templates to jinja2 #170

mwasilew opened this issue Jan 10, 2018 · 4 comments
Assignees

Comments

@mwasilew
Copy link
Contributor

Imported from https://projects.linaro.org/browse/QA-1739

@chaws
Copy link
Collaborator

chaws commented Oct 11, 2018

Just a follow-up:

I'm half way done migrating templates to Jinja2: https://github.com/chaws/squad/tree/migrate-templates-to-jinja2

One big issue I stumbled across was Django Rest Framework's (DRF) support do Jinja2: it doesn't[1] have much.

This means that the whole /api part of the frontend will need to be handled with Django's default template engine (DTL), while the rest is being migrated to Jinja2. I managed to work around that by tweaking folders/settings a bit. Now most of migrated templates will be in squad/frontend/templates/jinja2, so that the Jinja2 engine knows that it should only look at that folder. I said most because rest_framework/api.html includes squad/_user_menu.html and both must be rendered using DTL so that /api works well with DRF. I couldn't think of anything better than keeping two copies of _user_menu: one (.html) for rest_framework/api.html and another (.jinja2) for jinja2/squad/base.jinja2. I'm open to suggestions.

I want to be done with this next week.

[1] encode/django-rest-framework#4084

@mwasilew
Copy link
Contributor Author

mwasilew commented Oct 11, 2018

IIUC the only difference here is:

 href="{% url 'settings-home' %}"

vs

href="{{url('settings-home')}}"

Maybe it would be possible to create a block here and fill in this block differently for different engines? I guess block handling is identical for django and jinja templates. I didn't try it, so take the advice with a pinch of salt.

@chaws
Copy link
Collaborator

chaws commented Oct 11, 2018

I thought about that too, but it would require checking all Django Rest Framework's templates (~70 files) and making blocks for their templates do work too. My idea here is to have 'https://qa-reports.linaro.org/api/*' using Django's template language (only because Django Rest Framework), and the rest using Jinja2. What do you think?

@chaws
Copy link
Collaborator

chaws commented Oct 18, 2018

Just opened a PR #377

@chaws chaws closed this as completed Oct 30, 2018
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

No branches or pull requests

2 participants