render

package
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 9, 2016 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

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 prefered settings, instead of just getting the defaults.

func New

func New(opts Options) *Engine

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

func (e *Engine) HTML(names ...string) Renderer

HTML renders the named files using the 'text/html' content type and the github.com/aymerick/raymond 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) JSON

func (e *Engine) JSON(v interface{}) Renderer

JSON renders the value using the "application/json" content type.

func (*Engine) RegisterHelper

func (e *Engine) RegisterHelper(name string, helper interface{})

See github.com/aymerick/raymond for more details on helpers.

func (*Engine) RegisterHelpers

func (e *Engine) RegisterHelpers(helpers map[string]interface{})

See github.com/aymerick/raymond for more details on helpers.

func (*Engine) String

func (e *Engine) String(s string) Renderer

String renderer that will run the string through the github.com/aymerick/raymond package and return "text/plain" as the content type.

func (*Engine) Template

func (e *Engine) Template(c string, names ...string) Renderer

Template renders the named files using the specified content type and the github.com/aymerick/raymond 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) XML

func (e *Engine) XML(v interface{}) Renderer

XML renders the value using the "application/xml" content type.

type EventSource

type EventSource struct {
	// contains filtered or unexported fields
}

func NewEventSource

func NewEventSource(w http.ResponseWriter) (*EventSource, error)

func (*EventSource) CloseNotify

func (es *EventSource) CloseNotify() <-chan bool

func (*EventSource) Flush

func (es *EventSource) Flush()

func (*EventSource) Write

func (es *EventSource) Write(t string, d interface{}) error

type Options

type Options struct {
	// HTMLLayout is the default layout to be used with all HTML renders.
	HTMLLayout string
	// TemplatesPath is the location of the templates directory on disk.
	TemplatesPath string
}

Options for render.Engine

type Renderer

type Renderer interface {
	ContentType() string
	Render(io.Writer, Data) error
}

Renderer interface that must be satisified 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

func HTML(names ...string) Renderer

HTML renders the named files using the 'text/html' content type and the github.com/aymerick/raymond 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 String

func String(s string) Renderer

String renderer that will run the string through the github.com/aymerick/raymond package and return "text/plain" as the content type.

func Template

func Template(c string, names ...string) Renderer

Template renders the named files using the specified content type and the github.com/aymerick/raymond 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 XML

func XML(v interface{}) Renderer

XML renders the value using the "application/xml" content type.

type RendererFunc

type RendererFunc func(io.Writer, Data) error

RendererFunc is the interface for the the function needed by the Func renderer.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL