* Karv Prime <karv.pr...@gmail.com> [170913 22:01]:
> It = html/template
> "The purpose" = the one I thought I could use it for and described above.

I'm still not sure you understand the capabilities of html/template.
This playground snippet might help you:

https://play.golang.org/p/_1KSiZbwh-

package main

import (
    "fmt"
    "html/template"
    "os"
)

var Trusted = `<div style="font-weight:bold">This Is Bold</div>`
var Untrusted = `<div style="display:none">pwnd</div>`

var MyHtml = `<body>
<p>{{.systemContent}}</p>
<p>{{.userContent}}</p>
</body>`

func main() {
    var tmpl, err = template.New("").Parse(MyHtml)
    if err != nil {
        fmt.Fprintf(os.Stderr, "error parsing template: %s\n", err)
        os.Exit(1)
    }
    var data = make(map[string]interface{})
    data["systemContent"] = template.HTML(Trusted)
    data["userContent"] = Untrusted
    err = tmpl.Execute(os.Stdout, data)
    if err != nil {
        fmt.Fprintf(os.Stderr, "error executing template: %s\n", err)
        os.Exit(1)
    }
}

You as the programmer get to decide which sources are trusted and which
are not.

If you are happy with goquery, as someone else suggested, that's fine.
But the template package may be simpler to work with and do what you
want.  Note that with template, you can put some, or even most, of your
logic in the template, or you can go the other way around and have only
simple {{.foo}} tags in the template that get replaced with large chunks
of HTML that you generate in your program (which seems to be very close
to what the Template Animation link encourages), or somewhere in
between.

...Marvin

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

Reply via email to