Page MenuHomePhabricator

Remove Twig templating engine
Open, Needs TriagePublic21 Estimated Story Points

Description

Since the laika frontend renders client-side we don't need a full templating engine anymore.

Acceptance criteria

  • Replace Twig with a class that collects the variables similar to Twig and outputs them into the data attribute in the Vue mount point.
  • Automatically map routes to JS entry points (replacing the individual JavaScript tags in current Twig templates).
  • Replace unit test checks that check for a specific output with checks that look for specific assignments in the template context.

Notes

  • The Twig template engine is still used in email templates.
  • Unit (and edge-to-edge) tests need to be changed, as some of them are checking template output that use some test templates.
  • Tests for the address change feature parses data attributes of the output.
  • Looking at the class TwigTemplate might help understanding what's required.
  • See the-silex-sunset for an example of how to create an event handler.

Possible Solution

3 SP

  • Introduce implementation of the interface Template that has the methods render() and assign().
  • Replace context array by calls to assign().
  • Replace all references to TwigTemplate by references to Template.

5 SP

  • All controllers must provide the entry point name to the templating engine.
  • Introduce middleware that injects the JS entry point into the request by using Symfony's HttpEventHandler. We currently assume that we have a 1:1 mapping between routes and entry point names (some of the entry points being reused for several routes).
  • (Change all calls to render() to provide the entry point name.)

13 SP

  • Create phabricator board containing tasks for each route.
  • Duplicate base_template.html.twig into [tbd.php].
  • Go through all calls (step-by-step) of getLayoutTemplate() and replace by getNewLayoutTemplate() making sure that unit tests still pass or are fixed respectively.
  • The Template implementation can have a getAssignedVariables() method to also be used in unit tests.
  • Change the method name of getNewLayoutTemplate() back to getLayoutTemplate().

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald TranscriptMar 25 2020, 11:33 AM
kai.nissen set the point value for this task to 5.Apr 9 2020, 10:35 AM
gabriel-wmde updated the task description. (Show Details)Jun 9 2020, 4:15 PM
gabriel-wmde removed the point value for this task.
kai.nissen updated the task description. (Show Details)Jun 15 2020, 10:05 AM
Restricted Application added a subscriber: Liuxinyu970226. · View Herald TranscriptJun 15 2020, 10:05 AM
kai.nissen updated the task description. (Show Details)Jun 15 2020, 10:59 AM
kai.nissen set the point value for this task to 21.
gabriel-wmde updated the task description. (Show Details)Aug 26 2020, 5:44 PM