vendredi 24 juin 2016

Hiding substituted value in HTML email template with CSS


My ITSM application can send HTML emails using templates but it uses simple substitution of keywords like [keyword1] which presence of (not null) I want to abuse to dynamically show or hide some data. For example the template might be: <body> <span>some label: [keyword1]</span> </body> Since most email clients won't run any client side scripts and the substitution engine on my ITSM is very limited I though I could use css with selectors to hide span if it has some (any) class and the class would be set to actual replaced value. I came up with css: span {visibility: visible; display: block; } span[class|=''] {visibility: hidden; display: none; } then in html template body: <table cellpadding="0" cellspacing="0" border="0" align="center"> <tr> <td width="200" valign="top"><span class="[something]">[something]</span></td> <td width="200" valign="top"><span class="">empty class value</span></td> <td width="200" valign="top"><span>span without class</span></td> </tr> </table> So the idea is that if replacement token value exists it will be assigned as class of the span hence remain visible but if it does not the class name will be empty hence hide span. The span without any class would also be visible. This works fine in Chrome when testing the concept and is hiding "empty class value" span only but does not work in actual email client Outlook 2010. Besides the fact that this approach is cumbersome while creating correct template since any span with any class will be hidden can anyone suggest how this can be achieved otherwise? EDIT: I have changed subject to better reflect the question

Aucun commentaire:

Enregistrer un commentaire