Skip to main content

(New Plugin) How to receive the HTML and CSS from Plugin v2?

In this article, you’ll learn how to save, retrieve, and work with HTML/CSS in Stripo Plugin v2 for optimized email delivery.

Elmira avatar
Written by Elmira
Updated over a month ago

When using Stripo Plugin v2, it's crucial to understand how to manage both editable (non-compiled) and compiled HTML and CSS, and how to extract them for your email campaigns.

What is Editable Code in Stripo Plugin v2?

Stripo Plugin v2 stores the editable (non-compiled) version of your email template. This version includes Stripo-specific class names and internal structures meant for editing purposes within the Stripo editor. It's not optimized for email delivery and cannot be used without further processing.

Before sending the email, this code needs to be compiled to ensure compatibility with email clients. If you want to store the editable code outside Stripo, you must retrieve it manually through Stripo’s API.

How to Save Editable Template Code?

You can retrieve the editable version of the HTML and CSS either via the JavaScript API or the Backend API.

  • Using the JavaScript API:

The getTemplateData method allows you to access the current HTML, CSS, and configuration data directly from the editor. This method is intended for client-side use and lets you extract the editable version of the email template.


More information can be found in the documentation.

  • Using the Backend API:

This method provides the same non-compiled code from the server side. This method is useful for maintaining compatibility with Plugin v1 or working with reference emails. The structure of the returned code is identical to what you see in the Stripo editor.


More details are available in the documentation.

Important note: If you need to maintain compatibility with Stripo Plugin v1, use the Backend API, as it returns HTML and CSS that work across both v1 and v2 versions.

How to Retrieve Compiled HTML and CSS?

Once your email template is edited, you need to compile it for email delivery. The compiled HTML and CSS are optimized for email clients: all styles are inlined, and Stripo-specific class names and structures are removed. This version is ready for delivery.

You can retrieve the compiled code using:

  • JavaScript API:

The compileEmail method generates the final version of the email, including HTML, AMP HTML, and other necessary components.


For more details, refer to the documentation.

  • Backend API:

The Backend API also provides a solution for compiling the template and returning the fully compiled version, ready for email delivery.

Learn more in the documentation.


How to Replace Saved HTML and CSS in Plugin V2?

If you've updated the HTML or CSS of your template and want to overwrite the previously saved module in Stripo, use the forceRecreate: true parameter during the next initialization of the editor.

What this does:

It instructs the editor to replace the existing code in Stripo's storage with the new version, but only during the first initialization after your update. You don’t need to use this parameter again after the initial replacement.

Conclusion:

Now you know how to retrieve, compile, and replace HTML and CSS in Stripo Plugin v2. Whether you're working client-side or server-side, both the JavaScript and Backend APIs offer flexible tools to help you manage and integrate email templates seamlessly into your workflow.


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?