diff --git a/README.md b/README.md index f75b73e..e349c42 100644 --- a/README.md +++ b/README.md @@ -10,11 +10,13 @@ Build with GO, TEMPL, HTMX & _HYPERSCRIPT [![Go](https://github.com/syarul/todomvc-go-templ-htmx-_hyperscript/actions/workflows/go.yml/badge.svg)](https://github.com/syarul/todomvc-go-templ-htmx-_hyperscript/actions/workflows/go.yml) -### Testing -As evidence of HTMX's capabilities in emulating the functionalities of modern frameworks, I have incorporated [unit test](https://github.com/syarul/todomvc-go-templ-htmx-_hyperscript/actions/runs/7412273948/job/20168687544) from https://github.com/cypress-io/cypress-example-todomvc. This demonstration serves to showcase that HTMX, when paired with _hyperscript, can replicate all the behaviors typically associated with most modern client frameworks. +### E2E Testing +As evidence of HTMX's capabilities in emulating the functionalities of modern frameworks, I have incorporated [cypress test](https://github.com/syarul/todomvc-go-templ-htmx-_hyperscript/actions/runs/7412273948/job/20168687544) from https://github.com/cypress-io/cypress-example-todomvc. This demonstration serves to showcase that HTMX, when paired with _hyperscript, can replicate if not all the behaviors typically associated with most modern client framework with minimum needs to write javascript. ### Security -Check on [this link](https://templ.guide/security/) when using `templ` as HTML template engine. At anytime as developer `Do not blame the farmer if you cook the rice til it burns.` +Check on [this link](https://templ.guide/security/) when using `templ` as HTML template engine. + +> `Do not blame the farmer if you cook the rice til it burns.` ### Usage - install go if you don't have @@ -24,10 +26,16 @@ Check on [this link](https://templ.guide/security/) when using `templ` as HTML t - finally run `go run .` - visit `http://localhost:8888` - alternatively you can compile into executable with `go build .` +- if you need to run the e2e testing make sure to have `nodejs` installed +- run in the root folder `git clone https://github.com/cypress-io/cypress-example-todomvc` +- `cd cypress-example-todomvc` +- `npm install` +- if you need to see the test in browser run `npm run cypress:open` +- for headless test `npm run cypress:run` ### HTMX Visit [https://github.com/rajasegar/awesome-htmx](https://github.com/rajasegar/awesome-htmx) to look for HTMX curated infos ### Todo -- Use behavior to modular the _hyperscript scripts \ No newline at end of file +- Perf test (consolidate with other langs rust, zig, odin, ocaml, etc+) \ No newline at end of file diff --git a/main.go b/main.go index a4dcb95..92ec7b4 100644 --- a/main.go +++ b/main.go @@ -92,7 +92,6 @@ func main() { t := &todos{} // Register the routes. - // http.Handle("/get-hash", http.HandlerFunc(t.getHash)) http.Handle("/set-hash", http.HandlerFunc(setHash)) http.Handle("/learn.json", http.HandlerFunc(learnHandler)) @@ -398,7 +397,6 @@ func (t *todos) updateTodo(w http.ResponseWriter, r *http.Request) { return } templRenderer(w, r, todoItem(todo, selectedFilter(filters))) - // } } func (t *todos) removeTodo(w http.ResponseWriter, r *http.Request) { diff --git a/todomvc.templ b/todomvc.templ index ff0f3c9..3f86f99 100644 --- a/todomvc.templ +++ b/todomvc.templ @@ -11,7 +11,6 @@ templ filter(filters []Filter) { for _, filter := range filters {
  • { filter.name } @@ -51,7 +50,8 @@ templ editTodo(todo Todo) { htmx.ajax('GET', `/update-todo?id=${@todo-id}&title=${my.value}`, {target: closest
  • , swap:'outerHTML'}) end send toggleMain to - send toggleFooter to " + send toggleFooter to + " /> } @@ -72,7 +72,8 @@ templ todoCheck(todo Todo) { if $toggleAll.checked and my.checked === false my.click() else if $toggleAll.checked === false and my.checked - my.click()" + my.click() + " /> } @@ -81,8 +82,7 @@ templ todoItem(todo Todo, filterName string) {
  • @todoCheck(todo) @@ -96,7 +96,8 @@ templ todoItem(todo Todo, filterName string) { add .editing to the closest
  • on htmx:afterRequest set $el to my.parentNode.nextSibling - set $el.selectionStart to $el.value.length" + set $el.selectionStart to $el.value.length + " > { todo.title } } } \ No newline at end of file