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

Notifications refactor #1577

Merged
merged 3 commits into from
Sep 20, 2019
Merged

Notifications refactor #1577

merged 3 commits into from
Sep 20, 2019

Conversation

ptbrowne
Copy link
Contributor

To prepare the way for stack managed email layouts, we separate email templating
in two phases.

  1. Rendering each individual generic part (emailSubtitle, emailTitle) from Handlebars to MJML
  2. Rendering the whole email Handlebars -> MJML -> HTML

To facilitate this process, templating management was centralized inside the Notification
class. Notification children classes now do not do the templating themselves, they only
prepare the data, define a template, and possibily add helpers to Handlebars.

@todo
Copy link

todo bot commented Sep 19, 2019

Do not pass templateData to global template function

// TODO Do not pass templateData to global template function
// templateData is passed to the global template function for now but it should change
// at some point since it is the stack that will do this part and it will
// not receive the application specific templateData
// To prevent this it would be good to also extract the *parts* inside bank-layout and
// compile them with the templateData.


This comment was generated by todo based on a TODO comment in b5e848d in #1577. cc @cozy.

- Notification class gains more responsibility -> children classes are
simpler
  - Does the two-phase templating
  - Gets data from children
  - Gets title/pushContent from children

Children classes of Notification are not involved in templating (apart
that they can define helpers).
Notification is the only class entrypoint for templating.

Some of the data preparation before rendering the template was done
inside each notifications/html/<notification-name>-html.js. It was moved
inside each Notification class.

For test purposes, the `fetchData` method was introduced in each Notification
class and is mocked inside tests with JSON data.
@ptbrowne ptbrowne merged commit 08df64a into master Sep 20, 2019
@ptbrowne ptbrowne deleted the refactor-notifs branch September 20, 2019 09:01
@ptbrowne ptbrowne restored the refactor-notifs branch September 20, 2019 09:01
@ptbrowne ptbrowne deleted the refactor-notifs branch September 20, 2019 09:01
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

Successfully merging this pull request may close these issues.

2 participants