mirror of
https://gitea.invidious.io/iv-org/shard-kemal.git
synced 2024-08-15 00:53:36 +00:00
28 lines
346 B
Markdown
28 lines
346 B
Markdown
# Views
|
|
|
|
You can use ECR to build views. Kemal serves a `render` macro to use built-in `ECR`
|
|
library.
|
|
|
|
## Writing Views
|
|
|
|
The ECR is actually ERB.
|
|
|
|
```
|
|
src/
|
|
views/
|
|
hello.ecr
|
|
```
|
|
|
|
Write `hello.ecr`
|
|
```erb
|
|
Hello <%= your_name %>
|
|
```
|
|
|
|
## Embedding View File
|
|
|
|
```crystal
|
|
get '/' do |env|
|
|
your_name = "Kemal"
|
|
render "views/hello.ecr"
|
|
end
|
|
```
|