From b669efdbd0df11fe54e0551294f4fc03e5ea9c96 Mon Sep 17 00:00:00 2001 From: Petrik de Heus Date: Wed, 14 Aug 2024 17:36:05 +0200 Subject: [PATCH] [ruby/sinatra-sequel] Use erb for templates (#8990) erb templates have better performance than slim templates. This also makes it more inline with the Ruby/sinatra tests, which also use erb. --- frameworks/Ruby/sinatra-sequel/Gemfile | 1 - frameworks/Ruby/sinatra-sequel/hello_world.rb | 5 +---- frameworks/Ruby/sinatra-sequel/views/fortunes.erb | 12 ++++++++++++ frameworks/Ruby/sinatra-sequel/views/fortunes.slim | 8 -------- frameworks/Ruby/sinatra-sequel/views/layout.erb | 11 +++++++++++ frameworks/Ruby/sinatra-sequel/views/layout.slim | 6 ------ 6 files changed, 24 insertions(+), 19 deletions(-) create mode 100644 frameworks/Ruby/sinatra-sequel/views/fortunes.erb delete mode 100644 frameworks/Ruby/sinatra-sequel/views/fortunes.slim create mode 100644 frameworks/Ruby/sinatra-sequel/views/layout.erb delete mode 100644 frameworks/Ruby/sinatra-sequel/views/layout.slim diff --git a/frameworks/Ruby/sinatra-sequel/Gemfile b/frameworks/Ruby/sinatra-sequel/Gemfile index 649fbcfe6bf..f4ac3eb1fe2 100644 --- a/frameworks/Ruby/sinatra-sequel/Gemfile +++ b/frameworks/Ruby/sinatra-sequel/Gemfile @@ -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 diff --git a/frameworks/Ruby/sinatra-sequel/hello_world.rb b/frameworks/Ruby/sinatra-sequel/hello_world.rb index e04d76a077b..822ceb5979c 100644 --- a/frameworks/Ruby/sinatra-sequel/hello_world.rb +++ b/frameworks/Ruby/sinatra-sequel/hello_world.rb @@ -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 @@ def rand1 ) @fortunes.sort_by!(&:message) - slim :fortunes + erb :fortunes, :layout=>true end # Test type 5: Database updates diff --git a/frameworks/Ruby/sinatra-sequel/views/fortunes.erb b/frameworks/Ruby/sinatra-sequel/views/fortunes.erb new file mode 100644 index 00000000000..3d27f4dc50f --- /dev/null +++ b/frameworks/Ruby/sinatra-sequel/views/fortunes.erb @@ -0,0 +1,12 @@ + + + + + +<% @fortunes.each do |fortune| %> + + + + +<% end %> +
idmessage
<%= fortune.id %><%= Rack::Utils.escape_html(fortune.message) %>
diff --git a/frameworks/Ruby/sinatra-sequel/views/fortunes.slim b/frameworks/Ruby/sinatra-sequel/views/fortunes.slim deleted file mode 100644 index 14c18a58bc7..00000000000 --- a/frameworks/Ruby/sinatra-sequel/views/fortunes.slim +++ /dev/null @@ -1,8 +0,0 @@ -table - tr - th id - th message - - for fortune in @fortunes - tr - td =fortune.id - td =fortune.message \ No newline at end of file diff --git a/frameworks/Ruby/sinatra-sequel/views/layout.erb b/frameworks/Ruby/sinatra-sequel/views/layout.erb new file mode 100644 index 00000000000..7d6715a3e98 --- /dev/null +++ b/frameworks/Ruby/sinatra-sequel/views/layout.erb @@ -0,0 +1,11 @@ + + + + Fortunes + + + +<%= yield %> + + + diff --git a/frameworks/Ruby/sinatra-sequel/views/layout.slim b/frameworks/Ruby/sinatra-sequel/views/layout.slim deleted file mode 100644 index 2be47605c04..00000000000 --- a/frameworks/Ruby/sinatra-sequel/views/layout.slim +++ /dev/null @@ -1,6 +0,0 @@ -doctype html -html - head - title Fortunes - body - == yield \ No newline at end of file