-
Notifications
You must be signed in to change notification settings - Fork 0
/
template.go
36 lines (31 loc) · 885 Bytes
/
template.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// Package turbostreams provides server-side support for sending Hotwired Turbo Streams in POST
// responses as well as over Action Cable.
package turbostreams
import (
_ "embed"
)
// Action is the Turbo Stream action.
type Action string
// Standard Turbo Stream actions.
const (
ActionAppend Action = "append"
ActionPrepend Action = "prepend"
ActionReplace Action = "replace"
ActionUpdate Action = "update"
ActionRemove Action = "remove"
ActionBefore Action = "before"
ActionAfter Action = "after"
)
// Message represents a Turbo Stream message which can be rendered to a string using the
// specified template.
type Message struct {
Action Action
Target string
Targets string
Template string
Data interface{}
}
// Template is a Go HTTP template string for rendering [Message] instances as HTML.
//
//go:embed streams.partial.tmpl
var Template string