Documentation
¶
Index ¶
- Variables
- func Add(key string, v View)
- func AddEditableView(name string)
- func AddTmplFunc(name string, fn interface{})
- func EditHandler(ctx dingo.Context)
- func Execute(ctx dingo.Context, key string, data interface{})
- func NewTmpl(name string) *template.Template
- type CoreView
- type EditTemplateData
- type EditableView
- type FileView
- type TemplateData
- type TemplateView
- type View
Constants ¶
This section is empty.
Variables ¶
var ( CanEdit = func(ctx dingo.Context) bool { return true } EmptyTmpl = "<!doctype html><head><title>Template Doesn't Exist</title></head>" + "<body>This template doesn't exist, or hasn't been created yet.</body></html>" UseCodeMirror = true CodeMirrorJS = "/js/libs/codemirror.js" CodeMirrorCSS = "/css/codemirror.css" )
var (
Path = "./templates"
)
Functions ¶
func AddTmplFunc ¶
func AddTmplFunc(name string, fn interface{})
AddTmplFunc adds a function to the templates functions.
func EditHandler ¶
EditHandler is a dingo.Handler that edits/saves a given template.
Types ¶
type CoreView ¶
CoreView is the most base view, implementing basic functionality.
func (*CoreView) Associations ¶
Associations returns this views associated views.
func (*CoreView) Extensions ¶
Extensions returns the list of extended views.
type EditTemplateData ¶
type EditTemplateData struct {
URL, DoneURL, DingoVer string
HasViews, IsAction, WasSaved bool
Error error
Views map[string]View
Content []byte
Stylesheets, Scripts string
}
EditTemplateData is data passed to the edit template.
type EditableView ¶
type EditableView struct { View // contains filtered or unexported fields }
Editable view wraps a view to be edited.
type FileView ¶
type FileView struct {
TemplateView
}
FileView reads a template from the file system.
type TemplateData ¶
TemplateData is a func that returns data for a given template used during rendering.
type TemplateView ¶
type TemplateView struct { CoreView Tmpl *template.Template TmplData TemplateData Bytes []byte }
Base template, extends core template.
func (*TemplateView) Data ¶
func (v *TemplateView) Data(ctx dingo.Context) []byte
Data returns the templates raw data, used for both rendering and editing.
func (*TemplateView) Execute ¶
func (v *TemplateView) Execute(ctx dingo.Context, data interface{}) error
Execute writes the template to the response using the given data.
func (*TemplateView) Init ¶
func (v *TemplateView) Init(name string, dataFunc TemplateData)
Init initializes the template
type View ¶
type View interface { Name() string Associate(names ...string) error Associations() []View Extends(name string) error Extensions() []View Data(ctx dingo.Context) []byte Reload(ctx dingo.Context) error Save(ctx dingo.Context, data []byte) error Execute(ctx dingo.Context, data interface{}) error }
View wraps a template and provides CRUD operations, and nesting of templates.
func NewEditable ¶
NewEditable returns a new editable FileView