Skip to content
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

ego confused by 'bulletproof button' #36

Open
kmanley opened this issue May 27, 2020 · 1 comment · May be fixed by #41
Open

ego confused by 'bulletproof button' #36

kmanley opened this issue May 27, 2020 · 1 comment · May be fixed by #41

Comments

@kmanley
Copy link

kmanley commented May 27, 2020

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 benbjohnson self-assigned this May 29, 2020
@benbjohnson
Copy link
Owner

@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.

@benbjohnson benbjohnson removed their assignment Nov 27, 2020
@bancek bancek linked a pull request Nov 22, 2021 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants