Skip to content

Commit

Permalink
Merge pull request #100 from xushiwei/q
Browse files Browse the repository at this point in the history
yap: param("name") => ${name}
  • Loading branch information
xushiwei authored Mar 9, 2024
2 parents 637f80f + 56bb489 commit 4363f2b
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 17 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ Let's create a file named [get_p_#id.yap](demo/classfile2_hello/get_p_%23id.yap)

```coffee
json {
"id": param("id"),
"id": ${id},
}
```

Expand All @@ -80,15 +80,15 @@ Execute `gop run .` and visit http://localhost:8080/p/123, you will get:

#### YAP Template

In most cases, we will not use the `html` directive to return a html page, but use the `yap` template engine. See [get_p_#id.yap](demo/classfile2_blog/get_p_%23id.yap):
In most cases, we don't use the `html` directive to generate html pages, but use the `yap` template engine. See [get_p_#id.yap](demo/classfile2_blog/get_p_%23id.yap):

```coffee
yap "article", {
"id": param("id"),
"id": ${id},
}
```

It means we need to find a template called `article` to render. See [yap/article_yap.html](demo/classfile2_blog/yap/article_yap.html):
It means finding a template called `article` to render. See [yap/article_yap.html](demo/classfile2_blog/yap/article_yap.html):

```html
<html>
Expand Down
2 changes: 1 addition & 1 deletion demo/classfile2_blog/get_p_#id.yap
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
yap "article", {
"id": param("id"),
"id": ${id},
}
2 changes: 1 addition & 1 deletion demo/classfile2_blog/gop_autogen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion demo/classfile2_hello/get_p_#id.yap
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
json {
"id": param("id"),
"id": ${id},
}
2 changes: 1 addition & 1 deletion demo/classfile2_hello/gop_autogen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions demo/classfile_blog/blog_yap.gox
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
get "/", ctx => {
ctx.html `<html><body>Hello, <a href="/p/123">YAP</a>!</body></html>`
}
get "/p/:id", ctx => {
ctx.yap "article", {
"id": ctx.param("id"),
}
}
get "/", ctx => {
ctx.html `<html><body>Hello, <a href="/p/123">YAP</a>!</body></html>`
}

run ":8888"
12 changes: 6 additions & 6 deletions demo/classfile_blog/gop_autogen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 4363f2b

Please sign in to comment.