Hello,
first a small remark on wording: I think you're using the verb "parse" with
the wrong definition here? You might mean something like "to replace html
in template tokens" instead of "to parse..." :-).
On Friday, May 4, 2018 at 10:42:57 AM UTC+2, Amandeep Kaur wrote:
>
> Where templateHtml is the email body with tokens and data is the interface
> holding dynamic values for these tokens. When I use ParseTemplate function
> to parse tokens as string values then it works fine. But if I have to parse
> html in one of my tokens then it parses html as string and in email
> displays html as string.
>
This is actually a "feature" caused by the html/template package security
model. You can read more on this in the
documentation: https://golang.org/pkg/html/template/#hdr-Security_Model
What happens is that content of `data interface{}`, typically provided by
the user and not the programmer, is considered "unsafe". Thus html in there
will be escaped.
However, if you (the programmer) know that the content of the specific
token `{{.TOKENNAME}}` is "safe" html, then you can cast it to
html/template.HTML (see https://golang.org/pkg/html/template/#HTML) before
Executing the template.
> Can anybody tell me what should I do to parse html in ParseTemplate
> function??
>
> Hope this clears up your problem,
Diego
--
You received this message because you are subscribed to the Google Groups
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.