|
| 1 | +import 'dart:io'; |
| 2 | +import 'package:mjml_bridge/mjml_bridge.dart'; |
| 3 | + |
| 4 | +const mjmlSource = r''' |
| 5 | +<mjml> |
| 6 | + <mj-body background-color="#F4F4F4"> |
| 7 | + <mj-section background-color="#ffffff" background-repeat="repeat" padding-bottom="0px" padding-top="30px" padding="20px 0" text-align="center"> |
| 8 | + <mj-column> |
| 9 | + <mj-image align="center" padding="10px 25px" src="https://static.mailjet.com/mjml-website/templates/christmas-logo.png" target="_blank" width="214px"></mj-image> |
| 10 | + <mj-text align="left" color="#55575d" font-family="Arial, sans-serif" font-size="13px" line-height="22px" padding-bottom="15px" padding-top="0px" padding="10px 25px"> |
| 11 | + <p style="text-align: center; margin: 10px 0;color:#151e23;font-size:14px;font-family:Georgia,Helvetica,Arial,sans-serif">Product | Concept | Contact</p> |
| 12 | + </mj-text> |
| 13 | + </mj-column> |
| 14 | + </mj-section> |
| 15 | + <mj-section background-repeat="repeat" padding-bottom="0px" padding-top="0px" padding="20px 0" text-align="center"> |
| 16 | + <mj-column> |
| 17 | + <mj-image align="center" padding-bottom="0px" padding-left="0px" padding-right="0px" padding-top="0px" padding="10px 25px" src="https://static.mailjet.com/mjml-website/templates/christmas-hero.jpg" target="_blank" width="600px"></mj-image> |
| 18 | + </mj-column> |
| 19 | + </mj-section> |
| 20 | + <mj-section background-color="#ffffff" background-repeat="repeat" background-size="auto" padding-bottom="0px" padding-top="30px" padding="20px 0" text-align="center"> |
| 21 | + <mj-column> |
| 22 | + <mj-text align="left" color="#55575d" font-family="Arial, sans-serif" font-size="30px" line-height="22px" padding-bottom="10px" padding-top="10px" padding="10px 25px"> |
| 23 | + <p style="line-height: 30px; margin: 10px 0; text-align: center; color:#151e23; font-size:30p; font-family:Georgia,Helvetica,Arial,sans-serif">- Our Holiday Recipes -</p> |
| 24 | + </mj-text> |
| 25 | + </mj-column> |
| 26 | + </mj-section> |
| 27 | + <mj-section background-color="#ffffff" background-repeat="repeat" padding-bottom="0px" padding="20px 0" text-align="center"> |
| 28 | + <mj-column> |
| 29 | + <mj-image align="center" padding-bottom="20px" padding-left="30px" padding-right="30px" padding-top="0px" padding="10px 25px" src="https://static.mailjet.com/mjml-website/templates/christmas-product-1.jpg" target="_blank" width="1200px"></mj-image> |
| 30 | + </mj-column> |
| 31 | + <mj-column> |
| 32 | + <mj-text align="left" color="#55575d" font-family="Arial, sans-serif" font-size="13px" line-height="22px" padding-bottom="0px" padding-left="40px" padding-right="40px" padding-top="0px" padding="10px 25px"> |
| 33 | + <p style="margin: 10px 0; color:#151e23; font-size:16px; font-family:Georgia,Helvetica,Arial,sans-serif"><b>Cake Title</b></p> |
| 34 | + <p style="line-height: 16px; margin: 10px 0;font-size:14px; color:#151e23; font-family:Georgia,Helvetica,Arial,sans-serif; color:#354552">Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo.</p> |
| 35 | + <p style="line-height: 16px; margin: 10px 0; color:#354552; font-size:14px; font-family:Georgia,Helvetica,Arial,sans-serif"><u>Choose me</u> ></p> |
| 36 | + </mj-text> |
| 37 | + </mj-column> |
| 38 | + </mj-section> |
| 39 | + <mj-section background-color="#ffffff" background-repeat="repeat" direction="rtl" padding-bottom="0px" padding-top="0px" padding="20px 0" text-align="center"> |
| 40 | + <mj-column> |
| 41 | + <mj-image align="center" padding-bottom="20px" padding-left="30px" padding-right="30px" padding-top="20px" padding="10px 25px" src="https://static.mailjet.com/mjml-website/templates/christmas-product-2.jpg" target="_blank" width="1200px"></mj-image> |
| 42 | + </mj-column> |
| 43 | + <mj-column> |
| 44 | + <mj-text align="left" color="#55575d" font-family="Arial, sans-serif" font-size="13px" line-height="22px" padding-bottom="0px" padding-left="40px" padding-right="40px" padding-top="0px" padding="10px 25px"> |
| 45 | + <p style="margin: 10px 0; color:#151e23; font-size:16px; font-family:Georgia,Helvetica,Arial,sans-serif"><b>Cake Title</b></p> |
| 46 | + <p style="line-height: 16px; margin: 10px 0;font-size:14px; color:#151e23; font-family:Georgia,Helvetica,Arial,sans-serif; color:#354552">Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo.</p> |
| 47 | + <p style="line-height: 16px; margin: 10px 0; color:#354552; font-size:14px; font-family:Georgia,Helvetica,Arial,sans-serif"><u>Choose me</u> ></p> |
| 48 | + </mj-text> |
| 49 | + </mj-column> |
| 50 | + </mj-section> |
| 51 | + <mj-section background-color="#ffffff" background-repeat="repeat" padding-bottom="0px" padding-top="0px" padding="20px 0" text-align="center"> |
| 52 | + <mj-column> |
| 53 | + <mj-image align="center" padding-bottom="20px" padding-left="30px" padding-right="30px" padding-top="20px" padding="10px 25px" src="https://static.mailjet.com/mjml-website/templates/christmas-product-3.jpg" target="_blank" width="1200px"></mj-image> |
| 54 | + </mj-column> |
| 55 | + <mj-column> |
| 56 | + <mj-text align="left" color="#55575d" font-family="Arial, sans-serif" font-size="13px" line-height="22px" padding-bottom="0px" padding-left="40px" padding-right="40px" padding-top="0px" padding="10px 25px"> |
| 57 | + <p style="margin: 10px 0; color:#151e23; font-size:16px; font-family:Georgia,Helvetica,Arial,sans-serif"><b>Cake Title</b></p> |
| 58 | + <p style="line-height: 16px; margin: 10px 0;font-size:14px; color:#151e23; font-family:Georgia,Helvetica,Arial,sans-serif; color:#354552">Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo.</p> |
| 59 | + <p style="line-height: 16px; margin: 10px 0; color:#354552; font-size:14px; font-family:Georgia,Helvetica,Arial,sans-serif"><u>Choose me</u> ></p> |
| 60 | + </mj-text> |
| 61 | + </mj-column> |
| 62 | + </mj-section> |
| 63 | + <mj-section background-color="#ffffff" background-repeat="repeat" padding-top="0px" padding="20px 0" text-align="center"> |
| 64 | + <mj-column> |
| 65 | + <mj-button align="center" background-color="#354552" border-radius="3px" color="#ffffff" font-family="Georgia, Helvetica, Arial, sans-serif" font-size="14px" font-weight="normal" inner-padding="10px 25px" padding="10px 25px" text-decoration="none" text-transform="none" vertical-align="middle">Discover all desserts</mj-button> |
| 66 | + </mj-column> |
| 67 | + </mj-section> |
| 68 | + <mj-section background-color="#ffffff" background-repeat="repeat" padding-bottom="0px" padding-top="0px" padding="20px 0" text-align="center"> |
| 69 | + <mj-column> |
| 70 | + <mj-image align="center" padding-bottom="0px" padding-left="0px" padding-right="0px" padding-top="0px" padding="10px 25px" src="https://static.mailjet.com/mjml-website/templates/christmas-footer.jpg" target="_blank" width="600px"></mj-image> |
| 71 | + </mj-column> |
| 72 | + </mj-section> |
| 73 | + <mj-section background-color="#ffffff" background-repeat="repeat" padding="20px 0" text-align="center"> |
| 74 | + <mj-column> |
| 75 | + <mj-image align="center" padding="10px 25px" src="https://static.mailjet.com/mjml-website/templates/christmas-logo.png" target="_blank" width="202px"></mj-image> |
| 76 | + <mj-social align="center"> |
| 77 | + <mj-social-element name="facebook"></mj-social-element> |
| 78 | + <mj-social-element name="pinterest"></mj-social-element> |
| 79 | + <mj-social-element name="instagram"></mj-social-element> |
| 80 | + </mj-social> |
| 81 | + </mj-column> |
| 82 | + </mj-section> |
| 83 | + </mj-body> |
| 84 | +</mjml> |
| 85 | +'''; |
| 86 | + |
| 87 | +void main() async { |
| 88 | + final result = await mjmlSource.render(); |
| 89 | + |
| 90 | + final server = await HttpServer.bind(InternetAddress.loopbackIPv4, 8080); |
| 91 | + server.listen((request) { |
| 92 | + request.response.headers.contentType = ContentType.html; |
| 93 | + request.response |
| 94 | + ..write(result.html) |
| 95 | + ..close(); |
| 96 | + }); |
| 97 | + |
| 98 | + if (Platform.isWindows) { |
| 99 | + await Process.run('cmd', ['/c', 'start', 'http://localhost:8080']); |
| 100 | + } else if (Platform.isMacOS) { |
| 101 | + await Process.run('open', ['http://localhost:8080']); |
| 102 | + } else if (Platform.isLinux) { |
| 103 | + await Process.run('xdg-open', ['http://localhost:8080']); |
| 104 | + } |
| 105 | +} |
0 commit comments