Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

initYapFS bugfix: checking exists #8

Merged
merged 1 commit into from
Jan 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions demo/classfile/blog.yapx.gox
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
type article struct {
ID string
}

get "/p/:id", ctx => {
ctx.yap "article", article{
ID: ctx.param("id"),
ctx.yap "article", {
"id": ctx.param("id"),
}
}

Expand Down
13 changes: 5 additions & 8 deletions demo/classfile/gop_autogen.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,17 @@ package main

import "github.com/goplus/yap"

type article struct {
ID string
}
type blog struct {
yap.App
}
//line demo/classfile/blog.yapx.gox:5
//line demo/classfile/blog.yapx.gox:1
func (this *blog) MainEntry() {
//line demo/classfile/blog.yapx.gox:5:1
//line demo/classfile/blog.yapx.gox:1:1
this.Get("/p/:id", func(ctx *yap.Context) {
//line demo/classfile/blog.yapx.gox:6:1
ctx.Yap__1("article", article{ID: ctx.Param("id")})
//line demo/classfile/blog.yapx.gox:2:1
ctx.Yap__1("article", map[string]string{"id": ctx.Param("id")})
})
//line demo/classfile/blog.yapx.gox:11:1
//line demo/classfile/blog.yapx.gox:7:1
this.Run__1(":8080")
}
func main() {
Expand Down
2 changes: 1 addition & 1 deletion demo/classfile/yap/article.yap
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
<meta charset="utf-8"/>
</head>
<body>
Article {{.ID}}
Article {{.id}}
</body>
</html>
8 changes: 6 additions & 2 deletions yap.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,12 @@ func New(fs ...fs.FS) *Engine {
}

func (p *Engine) initYapFS(fsys fs.FS) {
if sub, e := fs.Sub(fsys, "yap"); e == nil {
fsys = sub
const name = "yap"
if f, e := fsys.Open(name); e == nil {
f.Close()
if sub, e := fs.Sub(fsys, name); e == nil {
fsys = sub
}
}
p.fs = fsys
p.tpls = make(map[string]Template)
Expand Down
Loading