You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+26-2
Original file line number
Diff line number
Diff line change
@@ -104,9 +104,9 @@ func Example() {
104
104
105
105
// Provide a render function. Here we are doing it manually, but there is a
106
106
// provided WithTemplateRenderer which can be used to work with `html/template`
107
-
h.HandleRender(func(ctx context.Context, data interface{}) (io.Reader, error) {
107
+
h.HandleRender(func(ctx context.Context, data *RenderContext) (io.Reader, error) {
108
108
tmpl, err:= template.New("thermo").Parse(`
109
-
<div>{{.C}}</div>
109
+
<div>{{.Assigns.C}}</div>
110
110
<button live-click="temp-up">+</button>
111
111
<button live-click="temp-down">-</button>
112
112
<!-- Include to make live work -->
@@ -506,3 +506,27 @@ In production it is often required to have multiple instances of the same applic
506
506
live has a PubSub element. This allows nodes to publish onto topics and receive those messages as if they were all
507
507
running as the same instance. See the [cluster example](https://github.com/jfyne/live-examples/tree/main/cluster) for
508
508
usage.
509
+
510
+
## Uploads
511
+
512
+
Live supports interactive file uploads with progress indication. See the [uploads example](https://github.com/jfyne/live-examples/tree/main/uploads)
513
+
for usage.
514
+
515
+
### Features
516
+
517
+
Accept specification - Define accepted file types, max number of entries, max file size, etc. When the client
518
+
selects file(s), the file metadata can be validated with a helper function.
519
+
520
+
Reactive entries - Uploads are populated in the `.Uploads` template context. Entries automatically respond
521
+
to progress and errors.
522
+
523
+
### Entry validataion
524
+
525
+
File selection triggers the usual form change event and there is a helper function to validate the uploads.
526
+
Use `live.ValidateUploads` to validate the incoming files. Any validation errors will be available in the `.Uploads`
527
+
context in the template.
528
+
529
+
### Consume the uploads
530
+
531
+
When a form is submitted files will first be uploaded to a staging area, then the submit event is triggered. Within the event
532
+
handler use the `live.ConsumeUploads` helper function to then move the uploaded files to where you need them.
0 commit comments