Documentation ¶
Overview ¶
Helper methods to combine webview templates with http requests objects
Uses the gorilla context library
Index ¶
- func GetAliasMap(req *http.Request) map[string]string
- func GetLayoutName(req *http.Request) string
- func GetViewName(req *http.Request) string
- func RedirectLocal(req *http.Request, path string)
- func RegisterView(req *http.Request, set webview.TreeSet)
- func Render(w http.ResponseWriter, req *http.Request)
- func RenderView(w http.ResponseWriter, req *http.Request, name string, data interface{}) error
- func SetAliasMap(req *http.Request, alias map[string]string)
- func SetLayoutName(req *http.Request, name string)
- func SetViewData(req *http.Request, data interface{})
- func SetViewName(req *http.Request, name string)
- type Reader
- func (r *Reader) Bytes(name string, def []byte) []byte
- func (r *Reader) Float(name string, def float64) float64
- func (r *Reader) Int(name string, def int64) int64
- func (r *Reader) Read(name, def string) (string, bool)
- func (r *Reader) ReadBytes(name string, def []byte) ([]byte, bool)
- func (r *Reader) ReadFloat(name string, def float64) (float64, bool)
- func (r *Reader) ReadInt(name string, def int64) (int64, bool)
- func (r *Reader) ReadUint(name string, def uint64) (uint64, bool)
- func (r *Reader) Str(name string, def string) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetAliasMap ¶
Get the alias that will be used to render the template
func GetLayoutName ¶
Return the layout defined, if nothing was set, returns layout/main.html
func GetViewName ¶
Return the name of the View from the request
func RedirectLocal ¶
Set the redirect information for the given request
func RegisterView ¶
Register the treeset and the alias name for the current request
func Render ¶
func Render(w http.ResponseWriter, req *http.Request)
Render the view configured to that request
This method will redirect if any of the Redirect* methods were called or will try to render the view configured with SetView{Name/Data}
func RenderView ¶
Render the given view using the alias and treeset registered for the current request
Use the RegisterView in your http pipeline beforer calling RenderView
func SetAliasMap ¶
Set the alias that will be used to render the template
func SetLayoutName ¶
Set the layout that will be used.
To render the view the layout should call {{ template "contents" }}
func SetViewData ¶
Set the data that should be used to render the template
func SetViewName ¶
Set the name of the view that should be rendered at Render
Types ¶
type Reader ¶
Read values from a url.Values object
func (*Reader) Read ¶
Read a string value form the values object, if no value is found return the default
The boolean flag is true only if the value was read form the map.
func (*Reader) ReadInt ¶
Read a integer value from the values object, if no value is found or a value cannot be converted to a integer, return the default
The boolean flag is true only if the value was read from the map and correctly converted