Copy link to clipboard
Copied
I need to prepare html for sending via the Postmark API.
Given the following:
<cfset vHTML = "<html><body><div>This is html</div></body></html>">What would be the cleanest way to arrive at:
<cfset vPostmarkHTML = "<html>\n<body>\n<div>This is postmark html</div>\n</body>\n</html>">i.e. surround every nested tag group with "\n" except the outer <html> group
Copy link to clipboard
Copied
<cfset vHTML = "<html><body><div>This is a div.</div><div>This is a second div.</div></body></html>">
<!--- Test both versions of line-feed, and see which fits your needs. --->
<!---<cfset LF=chr(10)>--->
<cfset LF="\n">
<cfset vPostmarkHTML = vHTML.replaceNoCase("<body>","#LF#<body>").replaceNoCase("<div>","#LF#<div>","all").replaceNoCase("</body>","</body>#LF#").replaceNoCase("</div>","</div>#LF#","all")>
<cfoutput>
<strong>vPostmarkHTML</strong><br>
#vPostmarkHTML#
</cfoutput>
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more