PylotLight / wails-htmx-templ-template

121 stars 9 forks source link

Template build bug #3

Closed Esword618 closed 11 months ago

Esword618 commented 1 year ago

I reported an error using the wails dev command.

image

I find it is the place mentioned in the picture below.

image
PylotLight commented 1 year ago

Hey,

Have you changed the components module import from changeme?

Double check at the top where the components import is coming from for me.

this section in app.go needs to match what's in the go.mod as we have to import the components module/folder.

import (
    "changeme/components"
...
)
PylotLight commented 11 months ago

Let me know if you have any further issues, otherwise will close this for now.

angelside commented 10 months ago

This was still an issue but I figured it out.

The reason is that TestPage() and ModalPreview() are not in the compiled components/templates_templ.go file. (But they are in templates.templ)


Implementation is missing for that "modal" thing:

In app.go add the modal page below /greet page

{"/greet", "Greet form"},
{"/modal", "Modal test"},

Build the template again:

You need templ binary in your path.

go install github.com/a-h/templ/cmd/templ@latest

Re-build the template

~ cd components
~ rm -rf templates_templ.go
~ templ generate
~ cd ..
~ wails dev

The real thing is; that now we need some way to watch and build templates on change.

image

PylotLight commented 10 months ago

@angelside FYI this looks like a different issue than the first user as far as I can tell but glad you figured it out.

The real thing is; that now we need some way to watch and build templates on change. templ generate --watch will watch the current directory and will templ files if changes are detected. https://templ.guide/commands-and-tools/hot-reload/#built-in

angelside commented 10 months ago

It was the same issue, that's why I found this issue. We will have the same error if we use it as-is.

Actually, it is easy to reproduce:

~ wails init -n "wails-htmx-templ-template" -t https://github.com/PylotLight/wails-htmx-templ-template
~ cd wails-htmx-templ-template
~ wails dev

Because your compiled templates do not have that function go fires the errors.

image

PylotLight commented 10 months ago

@angelside Apologies you were correct, I wasn't reading the messages properly or something :P Updated those files now, cheers!