Mustache Templating

Mustache is a templating library that enables replacing keys in a text document with values provided by a data source.

The Remote Detailing Player fully supports Mustache Templating in the OCE app on iPad, and the HCP Viewer (see JSON Injection).

CRM Attributes in Presentations

Following is a list of CRM attributes accessible dynamically from within a ZIP presentation using Mustache.

Account fields:

  • email
  • lastname
  • firstname
  • addresses
  • state
    • city
    • addressid
    • postalarea
    • line1
  • customertype
  • salutation
  • onekeyid
  • nationality
  • isPrimary
  • id
  • specialty
  • account_type
  • middle_name
  • suffix_name
  • user_name

Presentation fields:

  • id
  • name
  • sequences

User fields:

  • employee_name
  • employee_firstname
  • employee_lastname

JSON Supplied to the Mustache Template

Following is an example of a JSON that is supplied to the Mustache template:

Copier
{
©
  },
  "sequenceIndex": 0,
  "presentations": [
    {
      "id": "a0qc0000002KqlwAAC",
      "name": "Survey CLM test",
      "sequences": [
        {
          "id": "a1Ac0000002HQ9WEAW",
          "slides": [
            {
              "name": "01_index.html"
            },
            {
              "name": "02_index.html"
            }
          ],
          "externalid": "SurveyCLMTest"
        }
      ]
    },
    {
      "id": "a0qc0000002L6IcAAK",
      "name": "test pvl",
      "sequences": [
        {
          "id": "a1Ac0000002HTCOEA4",
          "slides": [
            {
              "name": "pdf page 1"
            }
          ],
          "externalid": "1"
        },
        {
          "id": "a1Ac0000002HTCPEA4",
          "slides": [
            {
              "name": "pdf page 2"
            }
          ],
          "externalid": "2"
        }
      ]
    }
  ],
  "customers": [
    {
      "email": "",
      "lastname": "MIELE",
      "firstname": "ANGELO",
      "addresses": [
        {
          "state": "",
          "city": "GALLIPOLIS",
          "addressid": "a00c0000006r3PXAAY",
          "postalarea": "45631",
          "line1": "100 JACKSON PIKE"
        }
      ],
      "customertype": "",
      "salutation": "",
      "onekeyid": "",
      "nationality": "",
      "isPrimary": true,
      "id": "001c000001D5IP5AAN",
      "specialty": "Acupuncturist",
      "account_type": "HCP",
      "middle_name": "",
      "suffix_name": "Mr.",
      "user_name": "ANGELO MIELE Mr."
    },
    {
      "email":"john.smith@gmail.com",
      "lastname":"KUMAR",
      "firstname":"ASHOK",
      "addresses":[
        {
         "state":"",
          "city":"OLYMPIA FIELDS",
          "addressid":"a00c00000068EmuAAE",
          "postalarea":"60461",
          "line1":"2555 LINCOLN HWY STE 211"
        }
      ],
      "customertype":"",
      "salutation":"",
      "onekeyid":"",
      "nationality":"",
      "isPrimary":true,
      "id":"001c000001D5IRzAAN",
      "specialty":"Family medicine",
      "account_type":"HCP",
      "middle_name":"",
      "suffix_name":"Mr.",
      "user_name":"ASHOK KUMAR Mr."
    }
  ],
  "slideIndex": 0
}

The structure of JSON properties is as follows:

  • currentMode: Current mode of the player.
  • state: Saved state of presentation (it is stored on mobile application).
  • sequenceIndex: Sequence index in the sequence array.
  • presentationIndex: Presentation index in the presentations array.
  • slideIndex: Slide index in the slides array.
  • presentations: Array of presentation objects.
    • id: Presentation ID.
    • name: Name of presentation.
    • sequences: Array of sequence objects.
      • id: Sequence ID.
      • slides: Array of slide objects.
        • name: Name of slide (that is, 01_index.html).
      • externalid: A sequence can be retrieved by externalid from template.
  • customers: Array of customer objects.
  • parameters: Array of supplementary parameters.
    • employee_name: User name.
    • employee_lastname: User last name.
    • employee_firstname: User first name.

Following is a template code example of how you can retrieve data from the JSON:

Copier
<div id="screen-container">
HELLO  
#customers  <!--this is a mustache loop -->
<span id="doc_name" class="template">{{firstname }} {{ lastname
}}</span>
/customers
,<br/>DO YOU WANT TO START THE VISIT?</span>
</div>

Note:   

The saveState() function isn't supported in Remote Detailing.

JSON Injection

In addition to the above, the following code allows the raw JSON, which is supplied to the Mustache template, to be used as a JavaScript object variable:

Copier
<script type="text/javascript">
var allData = {{{.}}};
</script>