Documentation ¶
Overview ¶
Package turbo provides everything you need for creating Turbolinks-style frontend applications.
TODO(ben) Stuff we need:
- tubro.CSRF for CSRF (obv)
Index ¶
- Constants
- func Handler(h http.Handler) http.Handler
- func IsTLS(r *http.Request) bool
- type Options
- type Render
- func (r *Render) Flash(w http.ResponseWriter, message string)
- func (r *Render) GetFlash(w http.ResponseWriter, req *http.Request) string
- func (r *Render) HTML(w http.ResponseWriter, req *http.Request, status int, name string, ...) error
- func (r *Render) Redirect(w http.ResponseWriter, req *http.Request, url string, notice ...string)
- func (r *Render) String(w http.ResponseWriter, req *http.Request, name string, binding interface{}, ...) (string, error)
- func (r *Render) TemplateLookup(t string) *template.Template
Constants ¶
View Source
const ( // TurbolinksReferrer is the header sent by the Turbolinks frontend on any // XHR requests powered by Turbolinks. We use this header to detect if the // current request was sent from Turbolinks. TurbolinksReferrer = "Turbolinks-Referrer" // TurbolinksCookie is the name of the cookie that we use to handle // redirect requests correctly. // // We name it `_turbolinks_location` to be consistent with the name Rails // give to the cookie that serves the same purpose. TurbolinksCookie = "_turbolinks_location" // DefaultFlashCookieName is the default name for the cookie containing // flash messages. DefaultFlashCookieName = "_turbo_message" )
View Source
const ( DefaultLeftDelim = "{{" DefaultRightDelim = "}}" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Render ¶
type Render struct {
// contains filtered or unexported fields
}
func (*Render) Flash ¶
func (r *Render) Flash(w http.ResponseWriter, message string)
Flash sets a flash message on the given response.
func (*Render) HTML ¶
func (r *Render) HTML(w http.ResponseWriter, req *http.Request, status int, name string, binding interface{}, partial ...bool) error
HTML renders an HTML template.
If the partial option is passed as true, the template will render without its layout.
func (*Render) Redirect ¶
Redirect redirects the user to the given URL. If a message is provided, it will be set as a flash message on the response.
Click to show internal directories.
Click to hide internal directories.