Find and replace Pardot PML with HML
08 Sep 2022
One of my colleagues needed to migrate dozens of e-mail templates from an older instance of Pardot to a newer one. The new Pardot kept complaining that old templates were in Pardot Merge Language (“PML”), e.g. %%first_name%%
, instead of Handlebars Merge Language (“HML”), e.g. {{first_name}}
. Here’s how I helped do the find-and-replace:
- Download, install, and open Notepad++, or some other text editor capable of doing find-and-replace with regular expressions.
- From old-Pardot, copy the HTML code (don’t be in the visual editor – be in the code editor) that you need to tidy up into a blank document in Notepad++.
- Make sure your cursor is at the beginning of the document, because sometimes “replace all” actually behaves as “replace all forward of this point” in Notepad++.
- In the toolbar, use Search -> Replace (or hit Ctrl + H).
- In “Find what,” enter:
%%(\w+)%%
- This means:
“find me a piece of text starting with
%%
, followed by 1 or more characters that are ‘alphanumeric or an underscore’ (\w+
), followed by another%%
. And take note ((...)
) of whatever’s in between the%%
’s as ‘variable #1.’” - You can tweak the
\w+
if you need to – I’m not sure exactly what’s inside the%%
’s of Pardot variable names. “Alphanumeric or an underscore” was just my first guess. Regexr.com is a great website for testing how well patterns like%%(\w+)%%
actually work as you invent them.
- This means:
- In “Replace with,” enter:
{{\1}}
- This means:
“Whatever you just found, replace the whole thing with
{{
, followed by the stuff you saved out as ‘variable #1’, followed by}}
.”
- This means:
- In “Search Mode,” choose the “Regular expression“ radio option.
- Click the “Replace All” button.
- If you need to replace any variable names, like changing
first_name
toRecipient.FirstName
, then in “Search Mode,” choose the “Normal“ radio option and replace{{first_name}}
with{{Recipient.FirstName}}
, for example … repeat for all variable names that have changed from old-Pardot to new-Pardot. - Copy the HTML out of Notepad++ and paste it into the new Pardot.
- See if new-Pardot is happy with your new-and-improved HTML code.
- Repeat for the e-mail’s text version, if needed.
- Repeat for the next e-mail you need to migrate.
Tip:
It’s a similar concept in VSCode as Notepad++, where you put the find-and-replace tool into “Use Regular Expression” mode while replacing PML with HML. (Alt + R to toggle it on and off).
- The find-phrase will still be
%%(\w+)%%
- In VSCode, the replacement is
{{$1}}
(with a dollar sign instead of a slash).