using html/template for SVG documents

438 views
Skip to first unread message

Manlio Perillo

unread,
Feb 27, 2015, 1:45:17 PM2/27/15
to golan...@googlegroups.com
Hi.

I'm trying to use html/template for the generation of SVG documents.
However SVG is an XML application, and it seems hmtl/template does not support XML.

The following template:

var svg = `
<?xml version="1.0" standalone="no"?>
<svg width="auto" height="auto" version="1.1"
</svg>
`

generates
&lt;?xml version="1.0" standalone="no"?>
<svg width="auto" height="auto" version="1.1"
</svg>


How hard is to modify html/template to support XML and friends?


Thanks  Manlio Perillo 

Rob Lapensee

unread,
Feb 27, 2015, 4:22:47 PM2/27/15
to golan...@googlegroups.com
I think the existing template stuff should work fine,
here are two examples:

using html/template:
http://play.golang.org/p/MS7tjeaH1G

using text/template:

Sebastien Binet

unread,
Feb 27, 2015, 4:49:14 PM2/27/15
to Rob Lapensee, golang-nuts
alternatively, there's also https://godoc.org/github.com/ajstarks/svgo
which provides a nice API to generate SVG documents.

-s
> --
> 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...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages