Skip to content

Commit

Permalink
Merge pull request #8 from xushiwei/blog
Browse files Browse the repository at this point in the history
initYapFS bugfix: checking exists
  • Loading branch information
xushiwei authored Jan 7, 2024
2 parents f4b6d7b + 3994e8b commit a228d34
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 17 deletions.
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

0 comments on commit a228d34

Please sign in to comment.