@travetto/email-inky 3.1.20 → 3.1.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/package.json +2 -2
- package/src/render/html.ts +2 -3
- package/src/render/markdown.ts +1 -2
- package/src/render/subject.ts +1 -2
package/README.md
CHANGED
|
@@ -39,11 +39,11 @@ export default inkyTpl(<>
|
|
|
39
39
|
Please see the [inky](https://github.com/zurb/inky) documentation for more information on the [component specifications](#https-get-foundation-emails-docs-inky-html)
|
|
40
40
|
|
|
41
41
|
## Conditionals and Substitutions
|
|
42
|
-
The underlying [Email](https://github.com/travetto/travetto/tree/main/module/email#readme "Email transmission module.") module is built on [mustache](https://github.com/janl/mustache.js/), which provides enough flexibility to enable sufficient power with minimal complexity and overhead.
|
|
42
|
+
The underlying [Email](https://github.com/travetto/travetto/tree/main/module/email#readme "Email transmission module.") module is built on [mustache](https://github.com/janl/mustache.js/), which provides enough flexibility to enable sufficient power with minimal complexity and overhead.
|
|
43
43
|
|
|
44
44
|
This means this module, while showing [inky](https://github.com/zurb/inky) components, will ultimately produce HTML/markdown that is [mustache](https://github.com/janl/mustache.js/) compatible. The syntax used by [mustache](https://github.com/janl/mustache.js/) and the syntax used by [JSX](https://en.wikipedia.org/wiki/JSX_(JavaScript)) are in conflict due to both of the tools relying on the uniqueness of `{}` brackets.
|
|
45
45
|
|
|
46
|
-
To that end, the module introduces additional components ([If Component](https://github.com/travetto/travetto/tree/main/module/email-inky/src/components.ts#L27), [Unless Component](https://github.com/travetto/travetto/tree/main/module/email-inky/src/components.ts#L29), and [For Component](https://github.com/travetto/travetto/tree/main/module/email-inky/src/components.ts#L30)) to assist with control flow logic. When it comes to variable substitution, and a desire to intermingle seamlessly with component properties, `
|
|
46
|
+
To that end, the module introduces additional components ([If Component](https://github.com/travetto/travetto/tree/main/module/email-inky/src/components.ts#L27), [Unless Component](https://github.com/travetto/travetto/tree/main/module/email-inky/src/components.ts#L29), and [For Component](https://github.com/travetto/travetto/tree/main/module/email-inky/src/components.ts#L30)) to assist with control flow logic. When it comes to variable substitution, and a desire to intermingle seamlessly with component properties, `{{value}}` can be used within a string value. To leverage substitutions outside of string contexts, a more formal version can be found in the [Value Component](https://github.com/travetto/travetto/tree/main/module/email-inky/src/components.ts#L28) component, but this cannot be integrated into properties (e.g. an href).
|
|
47
47
|
|
|
48
48
|
## Template Extension Points
|
|
49
49
|
The template extension points are defined at:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@travetto/email-inky",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.22",
|
|
4
4
|
"description": "Email Inky templating module",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"email",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"foundation-emails": "^2.4.0"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
|
-
"@travetto/email-template": "^3.1.
|
|
37
|
+
"@travetto/email-template": "^3.1.18"
|
|
38
38
|
},
|
|
39
39
|
"peerDependencies": {
|
|
40
40
|
"@travetto/cli": "^3.1.6"
|
package/src/render/html.ts
CHANGED
|
@@ -82,8 +82,7 @@ const visit = (el: JSXElement, onVisit: (fn: JSXElement) => boolean | undefined
|
|
|
82
82
|
export const Html: RenderProvider<RenderContext> = {
|
|
83
83
|
finalize: (html, context) => html
|
|
84
84
|
.replace(/(<[/](?:a)>)([A-Za-z0-9$])/g, (_, tag, v) => `${tag} ${v}`)
|
|
85
|
-
.replace(/(<[uo]l>)(<li>)/g, (_, a, b) => `${a} ${b}`)
|
|
86
|
-
.replace(/[\[]{2}([^\]]+)[\]]{2}/gm, (_, t) => `{{${t}}}`),
|
|
85
|
+
.replace(/(<[uo]l>)(<li>)/g, (_, a, b) => `${a} ${b}`),
|
|
87
86
|
|
|
88
87
|
For: async ({ recurse, props }) => `{{#${props.attr}}}${await recurse()}{{/${props.attr}}}`,
|
|
89
88
|
If: async ({ recurse, props }) => `{{#${props.attr}}}${await recurse()}{{/${props.attr}}}`,
|
|
@@ -365,7 +364,7 @@ export const Html: RenderProvider<RenderContext> = {
|
|
|
365
364
|
};
|
|
366
365
|
|
|
367
366
|
export const HtmlWrap = async (content: string): Promise<string> => {
|
|
368
|
-
const wrapper = await new EmailResource(['@', '@travetto/email-inky
|
|
367
|
+
const wrapper = await new EmailResource(['@', '@travetto/email-inky#resources'])
|
|
369
368
|
.read('/email/inky.wrapper.html');
|
|
370
369
|
|
|
371
370
|
// Get Subject
|
package/src/render/markdown.ts
CHANGED
|
@@ -8,8 +8,7 @@ const ignore = async ({ recurse: _ }: RenderState<JSXElement, RenderContext>): P
|
|
|
8
8
|
export const Markdown: RenderProvider<RenderContext> = {
|
|
9
9
|
finalize: (text, context) => text
|
|
10
10
|
.replace(/(\[[^\]]+\]\([^)]+\))([A-Za-z0-9$]+)/g, (_, link, v) => v === 's' ? _ : `${link} ${v}`)
|
|
11
|
-
.replace(/(\S)\n(#)/g, (_, l, r) => `${l}\n\n${r}`)
|
|
12
|
-
.replace(/[\[]{2}([^\]]+)[\]]{2}/gm, (_, t) => `{{${t}}}`),
|
|
11
|
+
.replace(/(\S)\n(#)/g, (_, l, r) => `${l}\n\n${r}`),
|
|
13
12
|
|
|
14
13
|
For: async ({ recurse, props }) => `{{#${props.attr}}}${await recurse()}{{/${props.attr}}}`,
|
|
15
14
|
If: async ({ recurse, props }) => `{{#${props.attr}}}${await recurse()}{{/${props.attr}}}`,
|
package/src/render/subject.ts
CHANGED
|
@@ -6,8 +6,7 @@ const empty = async (): Promise<string> => '';
|
|
|
6
6
|
const visit = ({ recurse }: RenderState<JSXElement, RenderContext>): Promise<string> => recurse();
|
|
7
7
|
|
|
8
8
|
export const Subject: RenderProvider<RenderContext> = {
|
|
9
|
-
finalize: text => text
|
|
10
|
-
.replace(/[\[]{2}([^\]]+)[\]]{2}/gm, (_, t) => `{{${t}}}`),
|
|
9
|
+
finalize: text => text,
|
|
11
10
|
|
|
12
11
|
For: async ({ recurse, props }) => `{{#${props.attr}}}${await recurse()}{{/${props.attr}}}`,
|
|
13
12
|
If: async ({ recurse, props }) => `{{#${props.attr}}}${await recurse()}{{/${props.attr}}}`,
|