Pass Variables to View
On The Route
You declare the route route and inside the block you declare the variable.
#src/routes/web.cr
get "/user" do |env|
name = "Joe"
render "src/views/hello.ecr"
end
Now inside the ecr file which is the view you want to render. You want to do an embedded tag with the name of the variable so it can show on your page.
On The View
Now inside the ecr file which is the view you want to render. You want to do an embedded tag with the name of the variable so it can show on your page.
#src/views/hello.ecr
<div>
<%= name %>
<div>