diff --git a/Makefile b/Makefile index 73ba7c1..cc8de80 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ # List of all .templ files -TEMPL_FILES := $(wildcard *.templ) +TEMPL_FILES := $(shell find templates -type f -name '*.templ') # Name of the generated file(s) from templ GENERATED_FILES := $(TEMPL_FILES:.templ=_templ.go) diff --git a/go.mod b/go.mod index 798174e..0a9bbb0 100644 --- a/go.mod +++ b/go.mod @@ -2,4 +2,4 @@ module sunshine.industries/temp-exercise go 1.21.7 -require github.com/a-h/templ v0.2.598 // indirect +require github.com/a-h/templ v0.2.598 diff --git a/go.sum b/go.sum index 55b8a53..0e72287 100644 --- a/go.sum +++ b/go.sum @@ -1,2 +1,4 @@ github.com/a-h/templ v0.2.598 h1:6jMIHv6wQZvdPxTuv87erW4RqN/FPU0wk7ZHN5wVuuo= github.com/a-h/templ v0.2.598/go.mod h1:SA7mtYwVEajbIXFRh3vKdYm/4FYyLQAtPH1+KxzGPA8= +github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= diff --git a/main.go b/main.go index 4798966..602ddc4 100644 --- a/main.go +++ b/main.go @@ -2,13 +2,15 @@ package main import ( "fmt" - "github.com/a-h/templ" "net/http" + + "sunshine.industries/temp-exercise/templates" + "github.com/a-h/templ" ) func main() { - component := hello("some name") - + component := templates.Hello("some name") + http.Handle("/", templ.Handler(component)) staticFs := http.FileServer(http.Dir("./static")) diff --git a/hello.templ b/templates/hello.templ similarity index 50% rename from hello.templ rename to templates/hello.templ index 7087105..9338eaf 100644 --- a/hello.templ +++ b/templates/hello.templ @@ -1,16 +1,16 @@ -package main +package templates var myVar string = "some string, changed. and more" var anotherVar string = "hoho, cool" -templ hello(name string) { +templ Hello(name string) { - This is the title of the webpage! - + This is the title of the the webpage! + - -

This is an example paragraph. Anything in the body tag will appear on the page, just like this p tag and its contents.

+ +

This is an example paragraph. Anything in the body tag will appear on the page, just like this p tag and its contents.

}