Skip to content

Commit

Permalink
[ruby/sinatra-sequel] Use erb for templates (#8990)
Browse files Browse the repository at this point in the history
erb templates have better performance than slim templates. This also
makes it more inline with the Ruby/sinatra tests, which also use erb.
  • Loading branch information
p8 authored Aug 14, 2024
1 parent b976fe8 commit b669efd
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 19 deletions.
1 change: 0 additions & 1 deletion frameworks/Ruby/sinatra-sequel/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ gem 'passenger', '~> 6.0', :platforms=>[:ruby, :mswin], :require=>false
gem 'puma', '~> 6.4', :require=>false
gem 'sequel', '~> 5.0'
gem 'sinatra', '~> 3.0', :require=>'sinatra/base'
gem 'slim', '~> 3.0'
gem 'unicorn', '~> 6.1', :platforms=>[:ruby, :mswin], :require=>false

group :mysql do
Expand Down
5 changes: 1 addition & 4 deletions frameworks/Ruby/sinatra-sequel/hello_world.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
# frozen_string_literal: true

# Configure Slim templating engine
Slim::Engine.set_options :format=>:html, :sort_attrs=>false

# Our Rack application to be executed by rackup
class HelloWorld < Sinatra::Base
configure do
Expand Down Expand Up @@ -73,7 +70,7 @@ def rand1
)
@fortunes.sort_by!(&:message)

slim :fortunes
erb :fortunes, :layout=>true
end

# Test type 5: Database updates
Expand Down
12 changes: 12 additions & 0 deletions frameworks/Ruby/sinatra-sequel/views/fortunes.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<table>
<tr>
<th>id</th>
<th>message</th>
</tr>
<% @fortunes.each do |fortune| %>
<tr>
<td><%= fortune.id %></td>
<td><%= Rack::Utils.escape_html(fortune.message) %></td>
</tr>
<% end %>
</table>
8 changes: 0 additions & 8 deletions frameworks/Ruby/sinatra-sequel/views/fortunes.slim

This file was deleted.

11 changes: 11 additions & 0 deletions frameworks/Ruby/sinatra-sequel/views/layout.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html>
<head>
<title>Fortunes</title>
</head>

<body>
<%= yield %>
</body>

</html>
6 changes: 0 additions & 6 deletions frameworks/Ruby/sinatra-sequel/views/layout.slim

This file was deleted.

0 comments on commit b669efd

Please sign in to comment.