(Plugin) JS API functions

In this article, you will learn how to reproduse save, preview and other buttons in your app using the JS API functions of Stripo plugin.

Marina Krivenets avatar
Written by Marina Krivenets
Updated over a week ago

Stripo Plugin JS API can be accessed via window.StripoApi js object. To see the full description of each function, switch to the API Documentation.

The list of available JS API functions:

  • "getTemplate" - You can use this function to save the updated template in your database. Call this method to save HTML and CSS separately to storage and later load them to the editor again.

This method returns HTML and CSS codes with plugin internal extra styles and editor markup.

Format: callback(HTML, CSS, width, height).

Example of using:

window.StripoApi.getTemplate((html, css)=>{console.log(html)})

  • "compileEmail" - This function will be useful for previewing in the browser or sending the ready email template through the email service. This method returns compiled and compressed HTML code ready to be sent to clients.

Format: callback(error, html, ampHtml, ampErrors).

Example of using:

window.StripoApi.compileEmail((error, html, ampHtml, ampErrors) => {console.log(html)})

  • "getTitle" - This method returns the email title.

  • "setTitle" - This method sets the email title.

  • "getHiddenPreHeader" - This method returns hidden preheader in emails.

  • "setHiddenPreHeader" - This method sets hidden preheader in emails.

  • "getGoogleAnnotations" - This method returns the inserted Gmail Promo Annotations microdata into the HTML code of opened email template in the editor.

The null value is returned if the microdata code is not presented there.
If any of the parameters are disabled or empty, then the empty data is returned (for example, discountCode: '').

You can find more information about every parameter on this page (press the "Generate my code" button and check the "Microdata Format" tab) or on our blog here.

  • "setGoogleAnnotations" - This method inserts/updates the Gmail Promo Annotations microdata in the HTML code of opened email template in the editor.

  • "allDataSaved" - This parameter helps to identify whether all changes are saved or not.

If something was not saved, it returns False; if everything is saved - True.

It can be applied only if you don’t use the Autosave option.

  • "showAmpErrorsModal" - Use this function to display the AMP validation errors in Stripo modal window if they are present in the email template.

A detailed description of this function you can find here.

Thank you for taking the time to read our articles. We hope you will find this information helpful.

If you have any additional questions, please email us at support@stripo.email.

We would be glad to talk with you.

Did this answer your question?