forked from mjmlio/mjml
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
55 lines (45 loc) · 1.3 KB
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
require('@babel/register')
const mjml2html = require('./packages/mjml/src/index')
const xml = `
<mjml>
<mj-head>
<mj-attributes>
<mj-all
padding="0px"
/>
<mj-wrapper
background-color="yellow"
padding="80px"
/>
</mj-attributes>
</mj-head>
<mj-body>
<mj-wrapper>
<mj-section>
<mj-column>
<mj-text>
lorem lorem lorem lorem lorem lorem lorem lorem lorem lorem lorem lorem lorem lorem lorem lorem lorem lorem lorem lorem lorem lorem lorem lorem lorem lorem lorem lorem lorem lorem lorem lorem lorem lorem lorem lorem lorem lorem lorem lorem lorem lorem
</mj-text>
</mj-column>
</mj-section>
</mj-wrapper>
</mj-body>
</mjml>
`
console.time('mjml2html')
const { html } = mjml2html(xml, {
beautify: true,
filePath: './test.mjml',
})
console.timeEnd('mjml2html')
if (process.argv.includes('--output')) {
console.log(html)
}
if (process.argv.includes('--open')) {
const open = require('open')
const path = require('path')
const fs = require('fs')
const testFile = path.resolve(__dirname, './test.html')
fs.writeFileSync(testFile, html)
open(testFile)
}