forked from mjmlio/mjml
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.js
More file actions
59 lines (49 loc) · 1.22 KB
/
test.js
File metadata and controls
59 lines (49 loc) · 1.22 KB
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
56
57
58
59
require('babel-register')
const mjml2html = require('./packages/mjml/src/index')
const xml = `
<mjml owa_desktop="true">
<mj-body>
<mj-hero
mode="fluid-height"
background-width="600px"
background-height="469px"
background-url="https://cloud.githubusercontent.com/assets/1830348/15354890/1442159a-1cf0-11e6-92b1-b861dadf1750.jpg"
background-color="#2a3448"
padding="100px 0px">
<!-- To add content like mj-image, mj-text, mj-button ... use the mj-hero-content component -->
<mj-text
padding="20px"
color="#ffffff"
font-family="Helvetica"
align="center"
font-size="45px"
line-height="45px"
font-weight="900">
GO TO SPACE
</mj-text>
<mj-button href="https://mjml.io/" align="center">
ORDER YOUR TICKET NOW
</mj-button>
</mj-hero>
</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 opn = require('opn')
const path = require('path')
const fs = require('fs')
const testFile = path.resolve(__dirname, './test.html')
fs.writeFileSync(testFile, html)
opn(testFile, {
wait: false,
})
}