livebud / bud

The Full-Stack Web Framework for Go
MIT License
5.58k stars 178 forks source link

Can't create routes with name begin in number #144

Open 012e opened 2 years ago

012e commented 2 years ago

When we create a route with a number at the beginning

❯ bud new controller 1 index
| 1:9: expected 'IDENT', found 1

The controller is not generated but the view is.

view/
├── 1
│   └── index.svelte
└── index.svelte
controller/
└── controller.go

Result in

view: render error conjure: generate "bud/view/_ssr.js". ✘ [ERROR] [plugin tranform_svelte_to_js] Unexpected token (2:9)
1: <script>
2:   export let 1s = []
            ^
3: </script>
4:

    svelte:./bud/view/1/index.svelte:2:29:
      2 │ import View1IndexSvelte from "./view/1/index.svelte"
matthewmueller commented 2 years ago

Ah good catch. I'm assuming you wanted multiple versions? For now, I'd probably suggest v1, v2.

If you manually fix that export does the rest of bud work? I'm wondering if the controller props are also affected.

012e commented 2 years ago

If you manually fix that export does the rest of bud work?

No it doesn't work, just 404 page not found

matthewmueller commented 2 years ago

Need to think more about this one. Can you explain why you want this @012e?

It's definitely possible to have controller/1/controllers.go, with the following:

package controller
type Controller struct {}
func (c *Controller) Index() { }

But the package /1 isn't really resourceful. Maybe it's nice for versioning? But then you could do v1/ which I think is more clear. I'm leaning towards handling this in custom routes.

012e commented 2 years ago

I don't need this. It's just an edge case I found.