Skip to content

Instantly share code, notes, and snippets.

@MEGApixel23
Last active November 28, 2018 09:37
Show Gist options
  • Save MEGApixel23/e6f8793d5316387178528c795c43f34b to your computer and use it in GitHub Desktop.
Save MEGApixel23/e6f8793d5316387178528c795c43f34b to your computer and use it in GitHub Desktop.

Revisions

  1. MEGApixel23 revised this gist Nov 28, 2018. No changes.
  2. MEGApixel23 revised this gist Nov 28, 2018. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions render.js
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,7 @@ const mustache = require('mustache');

    /**
    * @param html
    * @param data has ths following structure:
    * @param data has the following structure:
    * {
    * pages: [
    * {
    @@ -23,7 +23,7 @@ const mustache = require('mustache');
    * }
    * ]
    * }
    * @param partials has pre-compiled CSS, JS and HTML parts. Has the following structure
    * @param partials has pre-compiled CSS, JS and HTML parts (strings). Has the following structure:
    * { barCode: String, css: String, vendor: String }
    *
    * @return String
  3. MEGApixel23 revised this gist Nov 28, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion render.js
    Original file line number Diff line number Diff line change
    @@ -28,6 +28,6 @@ const mustache = require('mustache');
    *
    * @return String
    */
    module.exports.render = (html, data, partials) => {
    module.exports = (html, data, partials) => {
    return mustache.render(html, data, partials);
    };
  4. MEGApixel23 revised this gist Nov 28, 2018. No changes.
  5. MEGApixel23 renamed this gist Nov 28, 2018. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  6. MEGApixel23 created this gist Nov 28, 2018.
    33 changes: 33 additions & 0 deletions handler.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,33 @@
    const mustache = require('mustache');

    /**
    * @param html
    * @param data has ths following structure:
    * {
    * pages: [
    * {
    * packages: {
    * dspName: String,
    * number: Number,
    * countAll: Number,
    * logo: String,
    * externalOrderId: String,
    * dspOrderId: String,
    * customerName: String,
    * address: String,
    * phone: String,
    * deliveryDate: String,
    * deliveryTime: String,
    * deliveryInstructions: string,
    * }
    * }
    * ]
    * }
    * @param partials has pre-compiled CSS, JS and HTML parts. Has the following structure
    * { barCode: String, css: String, vendor: String }
    *
    * @return String
    */
    module.exports.render = (html, data, partials) => {
    return mustache.render(html, data, partials);
    };
    69 changes: 69 additions & 0 deletions template.html
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,69 @@
    <html>
    <head>
    <style>{{> css }}</style>
    <script>{{> vendor }}</script>
    </head>
    <body>
    {{# pages }}
    <div class="page">
    {{# packages }}
    <div class="package">
    <div class="header-container">
    <div class="header pull-left corporate-name">{{ dspName }}</div>
    <div class="header pull-right packages">{{ number }}/{{ countAll }}</div>
    </div>
    <div class="center">
    {{# logo }}
    <img class="logo" src="{{{ logo }}}" />
    {{/ logo }}
    </div>
    <div class="info center">
    <table class="details">
    <tr>
    <td class="heading">Order #:</td>
    <td>{{ externalOrderId }}</td>
    </tr>
    {{# dspOrderId }}
    <tr>
    <td class="heading">{{ dspName }} Order ID:</td>
    <td>{{ dspOrderId }}</td>
    </tr>
    {{/ dspOrderId }}
    <tr>
    <td class="heading">Name:</td>
    <td>{{ customerName }}</td>
    </tr>
    <tr>
    <td class="heading">Address:</td>
    <td>
    {{# address }}
    <div>{{ item }}</div>
    {{/ address }}
    </td>
    </tr>
    <tr>
    <td class="heading">Phone #:</td>
    <td>{{ phone }}</td>
    </tr>
    <tr>
    <td class="heading">Delivery Date:</td>
    <td>{{ deliveryDate }}</td>
    </tr>
    <tr>
    <td class="heading">Delivery Time:</td>
    <td>{{ deliveryTime }}</td>
    </tr>
    <tr>
    <td>
    <div class="instructions-icon"></div>
    </td>
    <td>{{ deliveryInstructions }}</td>
    </tr>
    </table>
    </div>
    </div>
    {{/ packages }}
    </div>
    {{/ pages }}
    </body>
    </html>