https://htmx.org logo
Join Discord
Powered by
# htmx-general
  • m

    miniature-lizard-24702

    09/02/2022, 8:33 PM
    I'm adding fragment support to golang's QuickTemplate (by Valyala)
  • m

    miniature-lizard-24702

    09/02/2022, 8:45 PM
    I guess I can just do it stack based and scrub fragments statements in fragment sources after the fact
  • m

    miniature-lizard-24702

    09/02/2022, 8:45 PM
    that works
  • m

    miniature-lizard-24702

    09/02/2022, 8:45 PM
    and it's simpler
  • c

    careful-cpu-82706

    09/02/2022, 9:03 PM
    Its great lib and it has theme system so yup, its prolly top tailwind ui lib and ye theyre limiting the boilerplate classes
  • c

    careful-cpu-82706

    09/02/2022, 9:04 PM
    theres so many ui libs for tailwind tho
  • c

    careful-cpu-82706

    09/02/2022, 9:04 PM
    it depends what do you need
  • c

    careful-cpu-82706

    09/02/2022, 9:04 PM
    Im more into making components from scratch tho, but it depends
  • m

    miniature-lizard-24702

    09/02/2022, 9:06 PM
    👍
  • m

    miniature-lizard-24702

    09/02/2022, 9:22 PM
    for each fragment with a fragment do you need to include the parameters of the previous fragments and parent if you want to use it?
  • m

    miniature-lizard-24702

    09/02/2022, 9:22 PM
    in the definition?
  • m

    mysterious-toddler-20573

    09/02/2022, 9:43 PM
    this is a tricky part
  • m

    mysterious-toddler-20573

    09/02/2022, 9:43 PM
    do you pass parameters in as a map?
  • m

    mysterious-toddler-20573

    09/02/2022, 9:43 PM
    Or are they strongly typed?
  • m

    miniature-lizard-24702

    09/02/2022, 9:46 PM
    strongly typed
  • m

    miniature-lizard-24702

    09/02/2022, 9:46 PM
    it's generated code
  • m

    miniature-lizard-24702

    09/02/2022, 9:47 PM
    more specifically I'm adding fragment support to https://github.com/valyala/quicktemplate
  • m

    miniature-lizard-24702

    09/02/2022, 9:48 PM
    I think If I use any variable it would have to be in every outer scope
  • m

    mysterious-toddler-20573

    09/02/2022, 9:48 PM
    OK, so that's a bit hard
  • m

    mysterious-toddler-20573

    09/02/2022, 9:49 PM
    what you need to do is analyze the scope for used symbols, and those become the arguments to the template
  • m

    mysterious-toddler-20573

    09/02/2022, 9:50 PM
    Copy code
    @parameters(users: List<User>)
    <html>
      <ul>
        #for(user in users)
         #fragment example
           <li>${user.email}</li>
         #end
        #end
       </ul>
    </html>
  • m

    mysterious-toddler-20573

    09/02/2022, 9:51 PM
    this is a made up templating language
  • m

    mysterious-toddler-20573

    09/02/2022, 9:51 PM
    but the right thing for the inner example fragment is to have a single implicit argument,
    user
  • m

    mysterious-toddler-20573

    09/02/2022, 9:51 PM
    even though
    users
    is in scope
  • m

    mysterious-toddler-20573

    09/02/2022, 9:51 PM
    😑
  • m

    mysterious-toddler-20573

    09/02/2022, 9:51 PM
    this is one area where dynamic languages are way easier
  • m

    mysterious-toddler-20573

    09/02/2022, 9:53 PM
    to do it right, for statically typed languages, you'd want to look at symbol usage rather than availability within a fragment
  • m

    miniature-lizard-24702

    09/02/2022, 9:53 PM
    I mean I could just add the parameter manually like this:
  • m

    mysterious-toddler-20573

    09/02/2022, 9:54 PM
    Also possible
  • m

    mysterious-toddler-20573

    09/02/2022, 9:54 PM
    but annoying
1...809810811...1146Latest