Skip to content

Commit

Permalink
Upgrade Streamlined dependency to 0.6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredcwhite committed Sep 8, 2024
1 parent 73ea49e commit 3ec30e2
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 3 deletions.
4 changes: 2 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ PATH
rouge (>= 3.0, < 5.0)
serbea (~> 2.1)
signalize (~> 1.3)
streamlined (>= 0.5.2)
streamlined (>= 0.6.0)
thor (~> 1.1)
tilt (~> 2.0)
zeitwerk (~> 2.5)
Expand Down Expand Up @@ -224,7 +224,7 @@ GEM
thor (~> 1.0)
tilt (~> 2.0)
yard (~> 0.9, >= 0.9.24)
streamlined (0.5.2)
streamlined (0.6.0)
serbea (>= 2.1)
zeitwerk (~> 2.5)
terminal-table (3.0.2)
Expand Down
67 changes: 67 additions & 0 deletions bridgetown-core/benchmark/erb-vs-streamlined.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

require "bundler"
Bundler.setup
require "benchmark/ips"
require "bridgetown"

include ::Streamlined::Renderable

def erb_out
@erbtmpl ||= Tilt::ErubiTemplate.new(
outvar: "@_erbout",
bufval: "Bridgetown::OutputBuffer.new",
engine_class: Bridgetown::ERBEngine
) { erb_content }
@erbtmpl.render(self)
end

def erb_content
<<~ERB
<p><%= 123 + 99 %></p>
<%= erb2_out %>
ERB
end

def erb2_out
@erb2tmpl ||= Tilt::ErubiTemplate.new(
outvar: "@_erbout",
bufval: "Bridgetown::OutputBuffer.new",
engine_class: Bridgetown::ERBEngine
) { erb2_content }
@erb2tmpl.render(self)
end

def erb2_content
<<~ERB
<p><%= version %></p>
ERB
end

def streamlined_out
html -> { <<~HTML
<p>#{text -> { 123 + 99 }}</p>
#{html -> { streamlined2_out }}
HTML
}
end

def streamlined2_out
<<~HTML
<p>#{text -> { version }}</p>
HTML
end

def version
"<s>#{Bridgetown::VERSION}</s>"
end

puts erb_out
puts "---"
puts streamlined_out.to_s

Benchmark.ips do |x|
x.report("erb") { erb_out }
x.report("streamlined") { streamlined_out.to_s }
end
2 changes: 1 addition & 1 deletion bridgetown-core/bridgetown-core.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ Gem::Specification.new do |s|
s.add_runtime_dependency("rouge", [">= 3.0", "< 5.0"])
s.add_runtime_dependency("serbea", "~> 2.1")
s.add_runtime_dependency("signalize", "~> 1.3")
s.add_runtime_dependency("streamlined", ">= 0.5.2")
s.add_runtime_dependency("streamlined", ">= 0.6.0")
s.add_runtime_dependency("thor", "~> 1.1")
s.add_runtime_dependency("tilt", "~> 2.0")
s.add_runtime_dependency("zeitwerk", "~> 2.5")
Expand Down

0 comments on commit 3ec30e2

Please sign in to comment.