Render is a package that provides functionality for easily rendering JSON, XML, text, binary data, and HTML templates. Render can be used with pretty much any web framework provided you can access the HTTP.ResponseWriter from your handler. The rendering functions simply wraps Go's existing functionality for marshaling and rendering data. HTML: Uses the html/template package to render HTML templates. JSON: Uses the encoding/json package to marshal data into a JSON-encoded response. XML: Uses the encoding/xml package to marshal data into an XML-encoded response. Binary data: Passes the incoming data straight through to the HTTP.ResponseWriter. Text: Passes the incoming string straight through to the http.ResponseWriter. Render comes with a variety of configuration options. By default Render will attempt to load templates with a '.tmpl' extension from the "templates" directory.
Features
- JSON vs Streaming JSON
- You can also load templates from memory by providing the Asset and AssetNames options
- Render provides yield and partial functions for layouts to access
- current can also be called to get the current template being rendered
- Partials are defined by individual templates
- Character Encodings