https://htmx.org logo
Join Discord
Powered by
# go-htmx
  • g

    gorgeous-ghost-95789

    04/26/2023, 12:18 AM
    I believe there is one already.
  • g

    gorgeous-ghost-95789

    04/26/2023, 12:20 AM
    I thought this used to be in the test suite, but you could always try this: https://github.com/benpate/sseplaceholder
  • g

    gorgeous-ghost-95789

    04/26/2023, 12:22 AM
    Sorry I missed this note when you posted it. If you’re still looking for a project to get involved with, check out: https://github.com/EmissarySocial/emissary — it’s htmx + go + ActivityPub. I’d love to have your help!
  • h

    hundreds-stone-62176

    05/10/2023, 8:31 PM
    Along the same lines as pushup.adhoc.dev, another Go web framework with htmx first-class support: https://templ.guide/server-side-rendering/htmx
  • a

    ancient-continent-47302

    05/11/2023, 4:53 AM
    Okay wow this looks perfect
  • a

    ancient-continent-47302

    05/11/2023, 4:53 AM
    Especially for a potential frontend framework in go
  • a

    ambitious-intern-12893

    05/11/2023, 8:34 AM
    As a clarification, templ is not a framework (yet). It's a HTML templating language where you can write Go code inline, so is a great fit to be used in conjunction with HTMX! I also agree @ancient-continent-47302 it looks perfect, but I'm a bit biased as a templ contributor! I've made a repo of a few examples: https://github.com/joerdav/go-htmx-examples
  • a

    ancient-continent-47302

    05/11/2023, 8:57 AM
    Yeah I realised that but I mean it’s a great fit for a golang wasm web framework.
  • a

    ancient-continent-47302

    05/11/2023, 8:57 AM
    Something like leptos (rust wasm) or solidjs
  • a

    ambitious-intern-12893

    05/11/2023, 9:11 AM
    Yeah, I think it'll fit in well with any web framework. It compiles down to Go so should just work with any.
  • c

    cuddly-keyboard-70746

    05/12/2023, 1:14 PM
    uhm under that definition any ssr that suports custom html attributes has first class support with htmx
  • c

    cuddly-keyboard-70746

    05/12/2023, 1:15 PM
    i appreciate the docs mention, but that doesnt feel super "first class" to me
  • h

    hundreds-stone-62176

    05/12/2023, 1:15 PM
    ¯\_(ツ)_/¯
  • m

    mysterious-car-3675

    05/12/2023, 2:03 PM
    been talking to Adrian, guy behind templ, to extend to be generic beyond html. May have introduced him to htmx
  • w

    worried-kangaroo-95467

    05/23/2023, 6:48 PM
    Any examples htmx-go and keycloak (or other OIDC IdP) for authn & authz ?
  • w

    white-architect-71886

    05/24/2023, 7:07 PM
    Not really with HTMX especially but a good intro is https://auth0.com/docs/quickstart/webapp/golang/interactive
  • s

    square-bird-9707

    05/25/2023, 9:55 PM
    hey guys, if anyone is looking for some go + htmx examples, i've been experimenting with it in the doc site i'm building. instead of fetching an entirely new page i just use an htmx swap to switch between pages. it works super well 👍 https://github.com/tylermmorton/torque/blob/master/www/docsite/routes/docs/docs.go
  • t

    thankful-balloon-21810

    05/26/2023, 1:09 AM
    I'm using the default
    html/template
    and I'm not sure what I do wrong here. for a certain route my code looks like this:
    Copy code
    go
    session := Get_Session(r)
    view := ProfileView{UserName: session.UserName}
    
    var tmpl *template.Template
    if r.Header.Get("HX-Request") == "true" {
        tmpl, _ = template.ParseFiles("htmx/profile.html")
        tmpl.ExecuteTemplate(w, "content", view)  // empty response
            //tmpl.Execute(w, view)  // empty response as well
    } else {
        tmpl, _ = template.ParseFiles("htmx/index.html", "htmx/profile.html")
        home_view := HomeView{
            Session: session,
            Content: view,
        }
        tmpl.Execute(w, home_view)  // works properly
    }
    index.html
    has a
    {{block "content" .Content}}{{end}}
    profile.html
    is a
    {{define "content"}} ... {{end}}
    do I need a dummy
    content.html
    just to have a different way to apply the template?
  • b

    bored-photographer-4726

    05/26/2023, 5:17 AM
    you're discarding the errors from
    ParseFiles
    and
    ExecuteTemplate
    . likely one of those will have a clue for you
  • s

    salmon-xylophone-28580

    05/27/2023, 7:58 PM
    A bit off-topic, since not directly related to htmx. I am looking for a type safe templating language for Go with support for autocomplete in vscode. But I want to type html (...) not call a function (Title(...)). Any recommendations?
  • g

    great-cartoon-12331

    05/27/2023, 8:07 PM
    how about normal Go templates with an
    .html
    extension? VSCode has built-in support for HTML
  • t

    thankful-balloon-21810

    05/27/2023, 8:47 PM
    I'm relatively new to Go, but so far I found that Go's html/template module is perfectly fine. You can make it kinda type safe by writing a function that only accept certain types for the data, but I guess that would make the code more confusing than it would be of any help.
  • s

    salmon-xylophone-28580

    05/28/2023, 7:14 AM
    The standard html templates are not type safe. I want to get a compile error if my template tries to access a field which does not exist. For example i accidentally type .Fooo instead of .Foo
  • m

    miniature-lizard-24702

    05/28/2023, 12:12 PM
    You can use code generated templates
  • m

    miniature-lizard-24702

    05/28/2023, 12:12 PM
    Like quicktemplate
  • m

    miniature-lizard-24702

    05/28/2023, 12:13 PM
    Or jade, hero etc
  • m

    mysterious-car-3675

    05/28/2023, 2:29 PM
    I use quick template... Compiles time errors are the best errors
  • t

    thankful-balloon-21810

    05/28/2023, 10:53 PM
    So far I have found 2 very good reasons not to use golang: 1. if you want to export a function, type, or field, it has to begin with a capital letter. 2. you can't just easily import a bunch of files from a subfolder (because structures their project anyways?)
  • g

    great-cartoon-12331

    05/28/2023, 11:09 PM
    in practice i have never found either of these to be an issue. using Go in production for more than a year now
  • t

    thankful-balloon-21810

    05/29/2023, 12:10 AM
    I'm sure it's not an issue once you get used to it. It's just one of these arbitrary constraints that cause quite some friction when you're just learning the language.