ego confused by 'bulletproof button'
kmanley opened this issue · 1 comments
kmanley commented
It's a common pattern in email templates to use 'bulletproof buttons'
https://www.litmus.com/blog/a-guide-to-bulletproof-buttons-in-email-design/
but this confuses ego, e.g. this snippet of HTML in an ego template
<table class="body-action" align="center" width="100%" cellpadding="0" cellspacing="0">
<tr>
<td align="center">
<div>
<!--[if mso]><v:roundrect xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w="urn:schemas-microsoft-com:office:word" href="<%=gifturl%>" style="height:45px;v-text-anchor:middle;width:200px;" arcsize="7%" stroke="f" fill="t">
<v:fill type="tile" color="#0072ce" />
<w:anchorlock/>
<center style="color:#ffffff;font-family:sans-serif;font-size:15px;">Get my gift!</center>
</v:roundrect><![endif]-->
<a href="<%=gifturl%>" class="button button--blue">Get my gift</a>
</div>
</td>
</tr>
</table>
causes ego to emit
//line email_gift_fulfilled_html.ego:33
_, _ = io.WriteString(w, html.EscapeString(fmt.Sprint(lib.FormatMoney(enrollment.Plan.GiftValue, 0, 2, false, true))))
//line email_gift_fulfilled_html.ego:33
_, _ = io.WriteString(w, " gift. It's now ready and \n you can pick it up here:\n </p>\n <table class=\"body-action\" align=\"center\" width=\"100%\" cellpadding=\"0\" cellspacing=\"0\">\n <tr>\n <td align=\"center\">\n <div>\n <!--[if mso]>")
//line email_gift_fulfilled_html.ego:40
{
var EGO v.roundrect
EGO.Attrs = map[string]string{
"xmlns:v": fmt.Sprint("urn:schemas-microsoft-com:vml"),
"xmlns:w": fmt.Sprint("urn:schemas-microsoft-com:office:word"),
"href": fmt.Sprint("<%=gifturl%>"),
"style": fmt.Sprint("height:45px;v-text-anchor:middle;width:200px;"),
"arcsize": fmt.Sprint("7%"),
"stroke": fmt.Sprint("f"),
"fill": fmt.Sprint("t"),
}
EGO.Yield = func() {
//line email_gift_fulfilled_html.ego:41
_, _ = i
which causes a subsequent compilation error
undefined: v in v.roundrect
undefined: v in v.fill
...etc...
benbjohnson commented
@kmanley Thanks for the bug report. Ego uses namespaces for Go packages but I forgot that some HTML (like bulletproof buttons) uses them. Let me think about how to fix it. Maybe we can ignore the namespace if xmlns
is defined on an element.