This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package examples | |
| import ( | |
| "context" | |
| "fmt" | |
| "log" | |
| "net/http" | |
| "os" | |
| "strconv" | |
| "time" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package site | |
| import ( | |
| "fmt" | |
| "github.com/dustin/go-humanize" | |
| build "github.com/starfederation/datastar/build" | |
| datastar "github.com/starfederation/datastar/sdk/go" | |
| ) | |
| templ Home() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| router.Route("/api", func(apiRouter chi.Router) { | |
| apiRouter.Route("/todos", func(todosRouter chi.Router) { | |
| todosRouter.Get("/", func(w http.ResponseWriter, r *http.Request) { | |
| sessionID, mvc, err := mvcSession(w, r) | |
| if err != nil { | |
| http.Error(w, err.Error(), http.StatusInternalServerError) | |
| return | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package examples | |
| import ( | |
| "context" | |
| "fmt" | |
| "log" | |
| "net/http" | |
| "os" | |
| "strconv" | |
| "time" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <div | |
| id="demo" | |
| data-signals="{ values: { 0: 0, 1: 0, 2: 0, 3: 0, 4: 0, 5: 0 } }" | |
| data-computed:bar="Object.values($values).join('')" | |
| data-on-signal-patch="@post('/examples/one_time_passcode')" | |
| > | |
| <h3>OTP Input:</h3> | |
| <div | |
| data-on:keydown__prevent=" | |
| const input = event.target; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class OtpInput extends HTMLElement { | |
| constructor() { | |
| super(); | |
| this.attachShadow({ mode: "open" }); | |
| this.values = []; | |
| } | |
| connectedCallback() { | |
| this.length = Number(this.getAttribute("length") || 6); | |
| this.values = Array(this.length).fill(""); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package examples | |
| import ( | |
| "context" | |
| "fmt" | |
| "log" | |
| "net/http" | |
| "os" | |
| "strconv" | |
| "time" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package examples | |
| import ( | |
| "github.com/go-chi/chi/v5" | |
| "github.com/starfederation/datastar-dev/site/auth" | |
| . "github.com/starfederation/datastar-dev/site/shared" | |
| "github.com/starfederation/datastar-go/datastar" | |
| "net/http" | |
| "regexp" | |
| ) |
OlderNewer