erb templates have better performance than slim templates. This also makes it more inline with the Ruby/sinatra tests, which also use erb.
@@ -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
@@ -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
@@ -73,7 +70,7 @@ class HelloWorld < Sinatra::Base
)
@fortunes.sort_by!(&:message)
- slim :fortunes
+ erb :fortunes, :layout=>true
end
# Test type 5: Database updates
@@ -0,0 +1,12 @@
+<table>
+<tr>
+ <th>id</th>
+ <th>message</th>
+</tr>
+<% @fortunes.each do |fortune| %>
+ <td><%= fortune.id %></td>
+ <td><%= Rack::Utils.escape_html(fortune.message) %></td>
+<% end %>
+</table>
@@ -1,8 +0,0 @@
-table
- tr
- th id
- th message
- - for fortune in @fortunes
- td =fortune.id
- td =fortune.message
@@ -0,0 +1,11 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <title>Fortunes</title>
+</head>
+
+<body>
+<%= yield %>
+</body>
+</html>
@@ -1,6 +0,0 @@
-doctype html
-html
- head
- title Fortunes
- body
- == yield