mrml icon indicating copy to clipboard operation
mrml copied to clipboard

Handle mj-html-attributes

Open nevans opened this issue 1 year ago • 6 comments

https://documentation.mjml.io/#mj-html-attributes

Here's an example of how I'd like to use it:

<mjml>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             
  <mj-head>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           
    <mj-html-attributes>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           
      <mj-selector path="a[href]">                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
        <mj-html-attribute name="clicktracking">off</mj-html-attribute>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            
      </mj-selector>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               
    </mj-html-attributes>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          
  </mj-head>
...

In order to disable SendGrid's clicktracking for specific emails or specific links (e.g. forgot password).

nevans avatar May 21 '24 22:05 nevans

Bump

Was trying to use mj-html-atttributes to inject attributes for my drag and drop editor.

codedninja avatar Apr 11 '25 21:04 codedninja

Feel free to open a PR if you have some free time 😉

jdrouet avatar Apr 12 '25 08:04 jdrouet

Started working on it last night. 😅

codedninja avatar Apr 12 '25 12:04 codedninja

I made progress but then I have hit a wall trying to think of how I wanted to structure the data output to be used by the renderer. I realized the official MJML package reads the rendered content and query selects the path, this basically his the same limitation as stated in the MRML README. https://github.com/jdrouet/mrml#missing-implementations

Just thought of an idea on how to do it but would need to implement a check the current element matches and if so pass the rest of the path down into the children.

Edit: I am currently thinking about just utilizing class selector instead of the full support of query selectors.

codedninja avatar Apr 21 '25 00:04 codedninja

Created a pull request with the first iteration of an implementation. #535

codedninja avatar Apr 22 '25 17:04 codedninja

Thank you @codedninja! @jdrouet thank you for this awesome package! Any chance you can review the PR?

hudcap avatar May 11 '25 04:05 hudcap