Menu icon Foundation
Escaping characters

I am creating templates for email notifications. Panni, by default encodes the characters by default. I am trying to create a helper that keeps "<<" and ">>" or converts from &lt; and &gt; to the "<<" and ">>" characters. 

PanniinkyHandlebarsescape

I am creating templates for email notifications. Panni, by default encodes the characters by default. I am trying to create a helper that keeps "<<" and ">>" or converts from &lt; and &gt; to the "<<" and ">>" characters. 

Rafi Benkual almost 3 years ago

What type of helpers are you creating? From a CMS?

There is a <raw> tag to wrap content with - it will be passed over without being converted https://github.com/zurb/inky/issues/28

 

<raw>don't change me!</raw>

David Diomede almost 3 years ago

Hi Rafi,

 

We are making email notification templates, over 150 to be exact, the company that created the systems decided that less than and greater than characters for merge fields were a bright idea. So, the filed slook like this: <<example_field>>.

 

I tried the raw with the sample below:

 

<p><raw><<sample_tag>></raw>></p>

The  output ends up looking looks like this:

Raw output

A similar issue, I need to output the raw link. Is there a way to do a raw output for links? I have links that go into our email delivery software the look like this, but end up forcing the script to quit when it reaches on the inliner. 

https://www.worldatwork.org/home/html/home.jsp?utm_source=direct&utm_medium=Email&utm_term=%%merge Subsets_.Name_%%&utm_content=Membership_%%wawstatus%%_%%return [clock format [clock seconds] -format "%m-%d-%Y"]%%_WaWHome&utm_campaign=%%outmail.messageid%%

The helper I have looks like this, I reworked from the handlebars example. The console says "Error when loading footer-links.js as a Handlebars helper" it seems to mostly work I have to use the triple {{{}} to force it to work.

module.exports = Handlebars.registerHelper('link', function(membership-url, privacy-url, unsubscribe-url, profile-url, logo-url) {
  
  membership-url = Handlebars.Utils.escapeExpression(membership-url);
  privacy-url = Handlebars.Utils.escapeExpression(privacy-url);
  unsubscribe-url  = Handlebars.Utils.escapeExpression(unsubscribe-url);
  profile-url  = Handlebars.Utils.escapeExpression(profile-url);
  logo-url  = Handlebars.Utils.escapeExpression(logo-url);


  var membership-url = '<a href="' + membership-url + '">';
  var privacy-url = '<a href="' + privacy-url + '">';
  var unsubscribe-url = '<a href="' + unsubscribe-url + '">';
  var profile-url = '<a href="' + profile-url + '">';
  var logo-url = '<a href="' + logo-url + '">';

  return new Handlebars.SafeString(membership-url);
  return new Handlebars.SafeString(privacy-url);
  return new Handlebars.SafeString(unsubscribe);
  return new Handlebars.SafeString(profile-url);
  return new Handlebars.SafeString(logo-url);
});

I'm wondering may be best to decode special characters after after the inliner process, to avoid any issues being thrown when inlining the css. 

 

Corey Schaaf almost 3 years ago

<<raw>> How about trying it this way instead <<raw>> ?

David Diomede almost 3 years ago

Thanks Corey,

No luck =(

The output resulted in this:

 

 <p><<raw>><<how about="" trying="" it="" this="" way="" instead="">><<raw>></raw></how></raw></p>

Corey Schaaf almost 3 years ago

David, who is your email provider by chance? I use listrak and have a similar issue for dynamic content that I inject with their tagging system. 

I actually opened a bug about this on Git Here. I believe it's being looked into. It has something to do with the inliner. 

https://github.com/jonkemp/inline-css/issues/41

David Diomede almost 3 years ago

Corey, 

 

We use software called Aptify which handles all of our automated messages. It's very specific and does not decode the &lt; and &gt; characters. I originally provided it that way, but or developers kicked it back to me and had me use the decoded << >> characters which makes Foundation stop and quit at the inky portion of the script. There is a encode/decode script, I haven't attempted it yet. Here is the link:

https://github.com/mathiasbynens/he/blob/master/README.md

 

Dave