M
M
Magic Code2020-07-30 13:31:34
ruby
Magic Code, 2020-07-30 13:31:34

Why doesn't erb parse the template?

For some reason, the erb template is not processed:

require 'sinatra'
require 'movie'

get('/movies') do
  @movie = Movie.new
  @movie.title = 'Jaws'
  erb :index
end

<div class="container">
        <h2 class="text-center p-3 my-3 bg-primary text-white"> Movies <h2>
        <ul class="list-group">
            <li class="list-group-item list-group-item-success"><%= Time.now %></li> // выдаст дословно Time.now
            <li class="list-group-item list-group-item-info"><%= 6 / 3 %></li> // результат не будет выведен
            <li class="list-group-item list-group-item-warning"><%= @movie.title %></li> //болты))
            <li class="list-group-item list-group-item-danger">go</li>
            <li class="list-group-item list-group-item-primary">here</li>
        </ul>
    </div>

For some reason, the template does not display the result, everything is displayed verbatim. Tell me, what's the matter, I took an example from a book. The template file is named index.erb

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question