Documentation ¶
Index ¶
- func GoTemplateEngine(input string, data map[string]interface{}, helpers map[string]interface{}) (string, error)
- func JSTemplateEngine(input string, data map[string]interface{}, helpers map[string]interface{}) (string, error)
- func MDTemplateEngine(input string, data map[string]interface{}, helpers map[string]interface{}) (string, error)
- type Data
- type Engine
- func (e *Engine) Func(s string, fn RendererFunc) Renderer
- func (e *Engine) HTML(names ...string) Renderer
- func (e *Engine) JSON(v interface{}) Renderer
- func (e *Engine) JavaScript(names ...string) Renderer
- func (e *Engine) Plain(names ...string) Renderer
- func (e *Engine) String(s string, args ...interface{}) Renderer
- func (e *Engine) Template(c string, names ...string) Renderer
- func (e *Engine) XML(v interface{}) Renderer
- type EventSource
- type Helpers
- type Options
- type Renderer
- func Func(s string, fn RendererFunc) Renderer
- func HTML(names ...string) Renderer
- func JSON(v interface{}) Renderer
- func JavaScript(names ...string) Renderer
- func Plain(names ...string) Renderer
- func String(s string, args ...interface{}) Renderer
- func Template(c string, names ...string) Renderer
- func XML(v interface{}) Renderer
- type RendererFunc
- type TemplateEngine
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GoTemplateEngine ¶ added in v0.7.4
func GoTemplateEngine(input string, data map[string]interface{}, helpers map[string]interface{}) (string, error)
GoTemplateEngine implements the TemplateEngine interface for using standard Go templates
func JSTemplateEngine ¶ added in v0.10.1
func JSTemplateEngine(input string, data map[string]interface{}, helpers map[string]interface{}) (string, error)
JSTemplateEngine renders files with a `.js` extension through Plush. It also implements a new `partial` helper that will run non-JS partials through `JSEscapeString` before injecting.
Types ¶
type Data ¶
type Data map[string]interface{}
Data type to be provided to the Render function on the Renderer interface.
type Engine ¶
type Engine struct {
Options
}
Engine used to power all defined renderers. This allows you to configure the system to your preferred settings, instead of just getting the defaults.
func New ¶
New render.Engine ready to go with your Options and some defaults we think you might like.
func (*Engine) Func ¶
func (e *Engine) Func(s string, fn RendererFunc) Renderer
Func renderer allows for easily building one of renderers using just a RendererFunc and not having to build a whole implementation of the Render interface.
func (*Engine) HTML ¶
HTML renders the named files using the 'text/html' content type and the github.com/gobuffalo/plush package for templating. If more than 1 file is provided the second file will be considered a "layout" file and the first file will be the "content" file which will be placed into the "layout" using "<%= yield %>". If no second file is provided and an `HTMLLayout` is specified in the options, then that layout file will be used automatically.
func (*Engine) JavaScript ¶ added in v0.10.1
JavaScript renders the named files using the 'application/javascript' content type and the github.com/gobuffalo/plush package for templating. If more than 1 file is provided the second file will be considered a "layout" file and the first file will be the "content" file which will be placed into the "layout" using "<%= yield %>". If no second file is provided and an `JavaScriptLayout` is specified in the options, then that layout file will be used automatically.
func (*Engine) Plain ¶ added in v0.9.1
Plain renders the named files using the 'text/plain' content type and the github.com/gobuffalo/plush package for templating. If more than 1 file is provided the second file will be considered a "layout" file and the first file will be the "content" file which will be placed into the "layout" using "<%= yield %>".
func (*Engine) String ¶
String renderer that will run the string through the github.com/gobuffalo/plush package and return "text/plain" as the content type.
func (*Engine) Template ¶
Template renders the named files using the specified content type and the github.com/gobuffalo/plush package for templating. If more than 1 file is provided the second file will be considered a "layout" file and the first file will be the "content" file which will be placed into the "layout" using "{{yield}}".
type EventSource ¶
type EventSource struct {
// contains filtered or unexported fields
}
EventSource is designed to work with JavaScript EventSource objects. see https://developer.mozilla.org/en-US/docs/Web/API/EventSource for more details
func NewEventSource ¶
func NewEventSource(w http.ResponseWriter) (*EventSource, error)
NewEventSource returns a new EventSource instance while ensuring that the http.ResponseWriter is able to handle EventSource messages. It also makes sure to set the proper response heads.
func (*EventSource) CloseNotify ¶
func (es *EventSource) CloseNotify() <-chan bool
CloseNotify return true across the channel when the connection in the browser has been severed.
func (*EventSource) Flush ¶
func (es *EventSource) Flush()
Flush messages down the pipe. If messages aren't flushed they won't be sent.
func (*EventSource) Write ¶
func (es *EventSource) Write(t string, d interface{}) error
type Helpers ¶ added in v0.8.0
type Helpers map[string]interface{}
Helpers to be included in all templates
type Options ¶
type Options struct { // HTMLLayout is the default layout to be used with all HTML renders. HTMLLayout string // JavaScriptLayout is the default layout to be used with all JavaScript renders. JavaScriptLayout string // TemplatesBox is the location of the templates directory on disk. TemplatesBox packr.Box // AssetsBox is the location of the public assets the app will serve. AssetsBox packr.Box // Helpers to be rendered with the templates Helpers Helpers // TemplateEngine to be used for rendering HTML templates TemplateEngines map[string]TemplateEngine }
Options for render.Engine
type Renderer ¶
Renderer interface that must be satisfied to be used with buffalo.Context.Render
func Func ¶
func Func(s string, fn RendererFunc) Renderer
Func renderer allows for easily building one of renderers using just a RendererFunc and not having to build a whole implementation of the Render interface.
func HTML ¶
HTML renders the named files using the 'text/html' content type and the github.com/gobuffalo/plush package for templating. If more than 1 file is provided the second file will be considered a "layout" file and the first file will be the "content" file which will be placed into the "layout" using "<%= yield %>".
func JSON ¶
func JSON(v interface{}) Renderer
JSON renders the value using the "application/json" content type.
func JavaScript ¶ added in v0.10.1
JavaScript renders the named files using the 'application/javascript' content type and the github.com/gobuffalo/plush package for templating. If more than 1 file is provided the second file will be considered a "layout" file and the first file will be the "content" file which will be placed into the "layout" using "<%= yield %>".
func Plain ¶ added in v0.9.1
Plain renders the named files using the 'text/html' content type and the github.com/gobuffalo/plush package for templating. If more than 1 file is provided the second file will be considered a "layout" file and the first file will be the "content" file which will be placed into the "layout" using "<%= yield %>".
func String ¶
String renderer that will run the string through the github.com/gobuffalo/plush package and return "text/plain" as the content type.
func Template ¶
Template renders the named files using the specified content type and the github.com/gobuffalo/plush package for templating. If more than 1 file is provided the second file will be considered a "layout" file and the first file will be the "content" file which will be placed into the "layout" using "{{yield}}".
type RendererFunc ¶
RendererFunc is the interface for the the function needed by the Func renderer.