@@ -23,6 +23,7 @@ const RTL_LOCALES = [
2323export interface GlobalTemplateValues {
2424 subject : FtlIdMsg ;
2525 action ?: FtlIdMsg ;
26+ preview ?: FtlIdMsg ;
2627}
2728
2829class Renderer extends Localizer {
@@ -79,22 +80,33 @@ class Renderer extends Localizer {
7980 * `subject` goes inside `mj-title` and `action` goes in a script in `metadata.mjml`
8081 * 2) We need to return a localized `subject` back to the mailer
8182 */
82- const { subject, action } = await this . getGlobalTemplateValues ( context ) ;
83+ const { subject, action, preview } = await this . getGlobalTemplateValues (
84+ context
85+ ) ;
8386 const localizeAndRenderSubject = this . localizeAndRender (
8487 l10n ,
8588 subject ,
8689 context
8790 ) ;
88- if ( action ) {
89- const [ localizedSubject , localizedAction ] = await Promise . all ( [
90- localizeAndRenderSubject ,
91- this . localizeAndRender ( l10n , action , context ) ,
92- ] ) ;
9391
94- context . subject = localizedSubject ;
92+ context . subject = await localizeAndRenderSubject ;
93+
94+ if ( action ) {
95+ const localizedAction = await this . localizeAndRender (
96+ l10n ,
97+ action ,
98+ context
99+ ) ;
95100 context . action = localizedAction ;
96- } else {
97- context . subject = await localizeAndRenderSubject ;
101+ }
102+
103+ if ( preview ) {
104+ const localizedPreview = await this . localizeAndRender (
105+ l10n ,
106+ preview ,
107+ context
108+ ) ;
109+ context . preview = localizedPreview ;
98110 }
99111 }
100112
@@ -123,6 +135,7 @@ class Renderer extends Localizer {
123135 html : rootElement . outerHTML ,
124136 text : localizedPlaintext ,
125137 subject : context . subject ,
138+ preview : context . preview || '' ,
126139 } ;
127140 }
128141
0 commit comments