question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Replace Jinja templates in the frontend with Angular.

See original GitHub issue

This is intended as a starter project for newer contributors.

We want to remove all the uses of Jinja from the frontend codebase and replace these with some AngularJS equivalent, with the ultimate aim of getting rid of Jinja so that pages serve and load faster. Each file in the list below has a list of occurrences of Jinja templates that need to be removed and replaced with an appropriate Angular substitute. As an example, you can take a look at this PR and see how changes were made in the file search_results_directive.html.

For new contributors: If you’re new to Angular, you can give this tutorial a try.

If you’d like to help with this issue, please select a file from the list below, put your name in parentheses next to it, and submit a PR after replacing all the jinja templates in that file. Once the PR is submitted, you can tick the checkboxes. Note that all filepaths should be assumed to start from core/templates/dev/head/pages.


Files to remove jinja templates from:

  • header_css_libs.html (see incomplete work #4958) @jathusan123
    • {% if MINIFICATION or not DEV_MODE %}
  • header_js_libs.html (see incomplete work #4958)
    • {% if MINIFICATION or not DEV_MODE %}
  • footer_js_libs.html (#5937)
    • {% if not DEV_MODE %}
  • collection_editor/collection_editor.html
    • {% if title %}
  • exploration_editor/exploration_editor.html
    • {% if title %}
  • library/library.html
    • {% if page_mode in ['group', 'search'] %}
  • error/error.html
    • {% if status_code == 400 %}

Note: This part (above quoted) of the issue is moved to #5597 as the fix appears to be a much larger work than a starter project.

Completed

  • exploration_player/exploration_player.html (previous work #5158) @vojtechjelinek
    • {% if exploration_version %}
    • {% if not iframed %} --> first occurrence
    • {% if not iframed %} --> second occurrence
  • base.html @hoangviet1993 #5048
    • {% if additional_angular_modules %}
    • {% if iframed %} (need other approch to remove!)
    • {% if DEV_MODE %}
    • {% if SITE_FEEDBACK_FORM_URL %}
  • exploration_player/learner_local_nav.html @WickedBrat #4261
    • {% if can_edit %}
    • {% if username %}
  • exploration_editor/settings_tab/settings_tab.html @code247 #4209
    • {% if can_modify_roles %}
    • {% if can_release_ownership %}
    • {% if can_delete %}
    • {% if can_unpublish %}
  • splash pages (All splash files need to be done in one PR) @DubeySandeep #3964
    • {% if not user_is_logged_in %}
      • splash/splash.html
      • splash/splash_ah0.html
      • splash/splash_ah1.html
      • splash/splash_ah2.html
      • splash/splash_ai0.html
      • splash/splash_ai1.html
      • splash/splash_ai2.html
      • splash/splash_ai3.html
      • splash/splash_at0.html
      • splash/splash_at1.html
      • splash/splash_at2.html
      • splash/splash_av0.html
      • splash/splash_av1.html
  • error/error.html @Nix07 #3969
    • {% if code == 400 %} --> first occurrence
    • {% if code == 400 %} --> second occurrence
    • {% if code == 400 %} --> third occurrence
  • preferences/preferences.html @ishucr7 #4019
    • {% if username %}
  • forum/forum.html @ishucr7 #4050
    • {% if on_localhost %}
  • exploration_editor/feedback_tab/feedback_tab.html @nithusha21 #4123
    • {% if user_email %} --> first occurrence
    • {% if not user_email %}
    • {% if user_email %} --> second occurrence
  • creator_dashboard/creator_dashboard.html @aks681 #4127
    • {% if not can_create_collections %}
    • {% if can_create_collections %} --> first occurrence
    • {% if can_create_collections %} --> second occurrence
  • exploration_editor/editor_tab/state_editor_responses.html @EvsChen
    • {% if SHOW_TRAINABLE_UNRESOLVED_ANSWERS %} --> first occurrence
    • {% if SHOW_TRAINABLE_UNRESOLVED_ANSWERS %} --> second occurrence
  • collection_player/collection_player.html @vojtechjelinek #5869
    • {% if collection_id %} (On a quick look we found that we can entirely remove this jinja template as this is of no use. So after complete investigation one can delete this template entirely)
    • {% if can_edit %}

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:110 (77 by maintainers)

github_iconTop GitHub Comments

1reaction
rahgurungcommented, Dec 11, 2018

@shubha1593 @debck I am already working on it. Thanks.

1reaction
vojtechjelinekcommented, Aug 15, 2018

@durgeshra I’ve assigned you to collection_player/collection_player.html @codeherlife Since @durgeshra would be working on collection player, do you want to work on header_css_libs.html and header_js_libs.html (both are similar and should be done together)?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Replace jinja2 with angularjs completely - flask - Stack Overflow
What jinja2 can achieve, the same can be achieved with Angular.js. My question is- are there any advantages of replacing jinja2 with angular.js...
Read more >
AngularJS vs Jinja | What are the differences? - StackShare
AngularJS can be classified as a tool in the "Javascript MVC Frameworks" category, while Jinja2 is grouped under "Templating Languages & Extensions".
Read more >
Flask by Example – Integrating Flask and Angular - Real Python
If you need to use a number of Angular tags, it's a good idea to change the template tags AngularJS uses with the...
Read more >
Using Python, Flask, and Angular to Build Modern Web Apps
In this series, you will learn how to create modern web applications with Python, Flask, and Angular.
Read more >
Jinja2 Explained in 5 Minutes! - codeburst
So, Jinja2 templating is being used. A template contains variables which are replaced by the values which are passed in when the template...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found