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().