1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

vweb: readme: list some features of vweb

This commit is contained in:
Alexander Medvednikov 2019-12-10 00:16:39 +03:00
parent cd54b2878e
commit 0650d58818

View File

@ -1,12 +1,20 @@
This is pre-alpha software. This is pre-alpha software.
## Features
- Very fast: performance of C on the web.
- Small binary: hello world website is <100 KB.
- Easy to deploy: just one binary file that also includes all templates.
No need to install any dependencies.
- Templates are precompiled, all errors are visible at compilation time,
not at runtime.
Lots of things are broken and not implemented yet in V and vweb. Lots of things are broken and not implemented yet in V and vweb.
There's no documentation yet, have a look at a simple example: There's no documentation yet, have a look at a simple example:
https://github.com/vlang/v/tree/master/examples/vweb/test_vweb_app.v https://github.com/vlang/v/tree/master/examples/vweb/vweb_example.v
There's also the V forum: https://github.com/vlang/vorum There's also the V forum: https://github.com/vlang/vorum
`vorum.v` contains all GET and POST actions. `vorum.v` contains all GET and POST actions.
@ -16,16 +24,16 @@ pub fn (app mut App) index() {
$vweb.html() $vweb.html()
} }
// TODO ['/post/:id/:title'] // TODO ['/post/:id/:title']
// TODO `fn (app App) post(id int)` // TODO `fn (app App) post(id int)`
pub fn (app App) post() { pub fn (app App) post() {
id := app.get_post_id() id := app.get_post_id()
post := app.retrieve_post(id) or { post := app.retrieve_post(id) or {
app.vweb.redirect('/') app.vweb.redirect('/')
return return
} }
comments := app.find_comments(id) comments := app.find_comments(id)
show_form := true show_form := true
$vweb.html() $vweb.html()
} }
@ -34,11 +42,11 @@ pub fn (app App) post() {
`index.html` is an example of the V template language: `index.html` is an example of the V template language:
```html ```html
@for post in posts @for post in posts
<div class=post> <div class=post>
<a class=topic href="@post.url">@post.title</a> <a class=topic href="@post.url">@post.title</a>
<img class=comment-img> <img class=comment-img>
<span class=nr-comments>@post.nr_comments</span> <span class=nr-comments>@post.nr_comments</span>
<span class=time>@post.time</span> <span class=time>@post.time</span>
</div> </div>
@end @end