-
Notifications
You must be signed in to change notification settings - Fork 935
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add conditional mso attribute to MJML elements #1561
Comments
Well, I keep this one open but here's my POV on that : However, if you want so, you can still do a custom component that do the same. Let's try to discuss a bit on this before closing/working on it |
I agree, as an attribute it would add complexity, and some users could misunderstand the use of this. |
I think the name would be misleading for a lot of people (would condition be a templating feature ?) I doubt it should be in the default MJML build ( with column/text/... ) |
Why would you need extra conditional statements over the ones already generated by MJML? I've build over 50 emails in MJML and have never once needed this. Can you give me a use case as to why you use and need this? |
The name can be changed to something more specific, as in @matthewahillman the specific example I was working on that got me thinking is a GIF. Outlook doesn't play animated GIFs, only displays first frame. It was nothing almost. So for Outlook, I wanted to hide GIF and display JPG image of a good frame. Partly, my problem was not realizing were combined. So I can't use if I need a condition, and have to specify <style> directly inside . The problem becomes a bit more apparent trying to wrap condition around element in . I don't want to use HTML, I want to use MJML elements. So here's what I ended up with, in case someone will be stuck on this: Body part:
And I had to add style too, as I had a problem with non-Outlook clients:
[class*="mso-hide"] might not be necessary, but since classes were modified I added that there just in case. This might not be the best solution, but it works well across multiple clients consistently. So back to my suggestion. Instead of doing this:
This can be done with:
Even if this doesn't turn into a feature, hopefully some people will find conversation helpful. There's no documentation on how to deal with mso conditions inside MJML or any recommendations. |
Well changing the name won't really change the fact that if we keep adding client specific attributes it would start to re-introduce what we want to abstract. I feel like this need is really specifc, you should just do a custom component at this point if you want to be safer about opening/closing mso conditionnal |
I need something @viktorix suggested very often too. 90% of my mails and mail contents can be built perfectly with mjml. But sometimes clients request much more special emails where you have to do the hard work by yourself. Most often this could be done with conditionals, sometimes i would have to do use raw html. Examples coming to my mind of things i had to do in the past:
I would not say that this feature should be omitted because it would making designing mails harder. You dont have to use it. But this feature would enable to build much more complex designs within mjml without having to use mj-raw. |
I would not say that this feature should be omitted because it would
making designing mails harder. You dont have to use it.
Don't get me wrong on this, i wouldn't mind if those client specific stuff
would be "easy" to solve by just adding much more components/attribute.
It's a bit counter logical on the framework philosophy where we want to
abstract as much thing as we can and remove. IMO it's the same issue with
custom attribute, it's like everyone want it, but no one came with a
solution where it can work for everyone and no one has yet tried to
implement this.
However, it's still available as the framework offer a full support of
custom component. Anyone can build a solution to this issue a open a PR so
we can discuss about code, implementation markup usage & conveniance and
drawbacks. And even if it's not merged, it can live its own life as a
component package where we can talk about on the official documentation.
There's still limitation to the current as stated in #1565 that mostly why
this is still open to suggestion & fix
|
Is your feature request related to a problem? Please describe.
Right now there's no easy way of adding conditional statements since they are comments and MJML strips them out from HTML, and if it's wrapped around mj element it's not parsed. So it requires extra mj-raw and hacky way of adding conditional statements.
Describe the solution you'd like
It would be very helpful to add an attribute to certain elements to specify conditional statement. For example:
This would result in:
An alternative to adding new attribute to existing element is to create a new element like
<mj-condition value="lte mso 11"> ... </mj-condition>
Describe alternatives you've considered
Right now to be able to add conditional statements (unless I missed something?) that somewhat works is:
I've had some issues with closed comments in order to make work in certain non-Outlook clients. Hence my proposal.
Additional context
MJML already adds automatic conditional statements when HTML is generated, so this would give user control over adding their own very easily.
The text was updated successfully, but these errors were encountered: