diff --git a/docs/README.md b/docs/README.md index 60dfe63..db787ac 100644 --- a/docs/README.md +++ b/docs/README.md @@ -14,7 +14,7 @@ Crystal is a programming language based on *Ruby* syntax. - Easy to learn and start to develop. - Since it's working on LLVM, it's too fast. - - Easy deploment to *Heroku*. + - Easy deployment to *Heroku*. ## The Name @@ -24,7 +24,7 @@ Kemal means *Mature, grown up* in Turkish. - [Getting Started Tutorial](./tutorial.md) - [Using Dynamic Views](./views.md) - - [Parsing HTTP requests and Form Data](./http-requests.md) + - [HTTP Requests and Responses](./http-requests.md) - [Uploading Files](./upload.md) - [Serving Static Files](./statics.md) - [Serving JSON API](./json.md) diff --git a/docs/http-requests.md b/docs/http-requests.md index 942bee1..f424a97 100644 --- a/docs/http-requests.md +++ b/docs/http-requests.md @@ -1,6 +1,6 @@ -# HTTP Requests +# Handling HTTP Request/Response -You should use `env` variable to handle HTTP params. For both `get` and `post` (and others) methods, you should use `env` object. +You should use `env` variable to handle HTTP Request/Response. For both `get` and `post` (and others) methods, you should use the yielded `env` object. ```ruby # Matches /hello/kemal diff --git a/docs/json.md b/docs/json.md index 1b0090e..7eb91f4 100644 --- a/docs/json.md +++ b/docs/json.md @@ -1,6 +1,6 @@ # Serving JSON API -Just use `to_json` method to return. +You need to return a ```JSON``` object or need to convert the existing object via `to_json`. ```ruby require "kemal" diff --git a/docs/statics.md b/docs/statics.md index 43f60b1..e4e8193 100644 --- a/docs/statics.md +++ b/docs/statics.md @@ -5,13 +5,13 @@ Add your files to `public` directory and Kemal will serve these files immediatel ``` app/ src/ - awesome_web_project.cr + your_app.cr public/ js/ jquery.js - awesome_web_project.js + your_app.js css/ - awesome_web_project.css + your_app.css index.html ``` @@ -21,8 +21,8 @@ Open index.html and add
- - + + ... diff --git a/docs/tutorial.md b/docs/tutorial.md index 3df4e1c..5a458b2 100644 --- a/docs/tutorial.md +++ b/docs/tutorial.md @@ -12,8 +12,8 @@ brew install crystal-lang You should create your application first: ``` -crystal init app awesome_web_project -cd awesome_web_project +crystal init app your_app +cd your_app ``` Then add *kemal* to the `shard.yml` file as a dependency. @@ -41,7 +41,7 @@ Installing kemal (master) ## 3. Include Kemal into your project -Open `awesome_web_project/src/awesome_web_project.cr` and require `kemal` to use Kemal. +Open `your_app/src/your_app.cr` and require `kemal` to use Kemal. ```ruby require 'kemal' @@ -60,21 +60,18 @@ end All the code should look like this: ```ruby -require "./crystal_test/*" require "kemal" -module AwesomeWebProject - get "/" do - "Hello World!" - end +get "/" do + "Hello World!" end ``` ## 5. Run your awesome web project. ``` -crystal build --release src/awesome_web_project.cr -./awesome_web_project +crystal build --release src/your_app.cr +./your_app ``` You should see some logs like these: diff --git a/docs/views.md b/docs/views.md index 79315b8..c91125d 100644 --- a/docs/views.md +++ b/docs/views.md @@ -1,11 +1,21 @@ # Views -You can use ECR to build views. Kemal serves a `render` macro to use built-in `ECR` +You can use ECR to build views. Kemal serves a `render` macro to use Crystal's built-in `ECR` library. +## Embedding View File + +```crystal +get '/' do |env| + your_name = "Kemal" + render "views/hello.ecr" +end +``` + ## Writing Views -The ECR is actually ERB. +ECR is pretty similar ERB(from Ruby). As you can see you can easily access the block variables in your view. In this +example `your_name` is available for use in the view. ``` src/ @@ -17,12 +27,3 @@ Write `hello.ecr` ```erb Hello <%= your_name %> ``` - -## Embedding View File - -```crystal -get '/' do |env| - your_name = "Kemal" - render "views/hello.ecr" -end -```