Export Plain Text

Similar to export HTML function, you can also export a design in plain text. This is useful if you want to send an email in multiple formats for different email clients.

unlayer.exportPlainText(function(data) {
  var json = data.design; // design json
  var text = data.text; // final text

  // Do something with the json and text
})

Callback Parameters

The exportPlainText callback returns the following parameters.

Name

Description

design

This is the JSON of the design

text

This is the full plain text of the design


Export Options

You can also pass certain options to this function as a second parameter.

Omit Content

You can configure which parts of the design you want to omit in the plain text. For example, you can choose to ignore images, links, or preheader text.

unlayer.exportPlainText(function(data) {
  var json = data.design;
  var text = data.text;
}, {
  ignoreLinks: true,
  ignoreImages: true,
  ignorePreheader: true
})

Name

Description

ignoreLinks

Links and buttons will not be included

ignoreImages

Image alt text will not be included

ignorePreheader

Pre-header text for emails will not be included.

Merge Tags

If you want the Merge Tags in your design to be replaced by different values, you can pass the mergeTags object to export options.

unlayer.exportPlainText(function(data) {
  var json = data.design;
  var text = data.text;
}, {
  mergeTags: {
    first_name: 'John',
    last_name: 'Doe'
  }
})

Did this page help you?