foundation / foundation-emails

Quickly create responsive HTML emails that work on any device and client. Even Outlook.
https://get.foundation/emails/docs/
MIT License
7.76k stars 1.09k forks source link

menu items should allow miscellaneous attributes #722

Open stevesmename opened 7 years ago

stevesmename commented 7 years ago

How can we reproduce this bug? Within Salesforce Marketing Cloud (and likely other email service providers), it's ideal to code in an alias on all links. Menu->item syntax strips out "alias" and other attributes on links.

Write out the HTML (or Inky code) that causes the issue.

 <menu>
        <item href="http://www.google.com/" alias="google_header">Google</item>
</menu>

What did you expect to happen?

<table class="menu">
  <tr>
    <td>
      <table>
        <tr>
          <th class="menu-item"><a href="http://www.google.com" alias="google_header">Google</a></th>
        </tr>
      </table>
    </td>
  </tr>
</table>

What happened instead?

<table class="menu">
  <tr>
    <td>
      <table>
        <tr>
          <th class="menu-item"><a href="http://www.google.com">Google</a></th>
        </tr>
      </table>
    </td>
  </tr>
</table>
Creativenauts commented 7 years ago

@stevesmename you have couple of options.

  1. Modify inky node module.
// <item>
    case this.components.menuItem:
      // Prepare optional target attribute for the <a> element
      var target = '';
      if (element.attr('target')) {
        target = ' target=' + element.attr('target');
      }
      var alias = '';
      if (element.attr('alias')) {
        alias = ' alias=' + element.attr('alias');
      }
      var classes = ['menu-item'];
      if (element.attr('class')) {
        classes = classes.concat(element.attr('class').split(' '));
      }
      return format('<th %s class="%s"><a href="%s"%s%s>%s</a></th>', attrs, classes.join(' '), element.attr('href'), target, alias, inner);
  1. Create a custom helper
stevesmename commented 7 years ago

@DerekBess thanks for the comment, I never thought of a custom helper. I don't like modifying core, or altering a contributed module without making a proper pull request. I am a fan of extending, which is my understanding what a custom helper essentially offers. When I can't go the route of using inky then I post a github issue such as this, "why I didn't use inky syntax" whenever it occurs.

I noticed your comment on another issue in the queue regarding using yaml for analytics. Thought your comment was very insightful on how to begin implementing yaml files into my development process.

Creativenauts commented 7 years ago

@stevesmename I don't like modifying core as well, which is why I have been going the custom helper route. I'm currently in the process of writing custom script that allows you to create your own custom inky tags without modifying core node module. I'll release the code when I get more time to focus on the task.

I'm still wrapping my head around the best way to implement yaml files into my base project folder.