roda 3.40.0 → 3.41.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8e87645db18482f3ad97d106e268d76b2567d074490f37d7e99d52d06e4e5483
4
- data.tar.gz: b84b082c2f27fcbd31254cb80de5e6610b7417e722eaf3dc3d8753a4604a0701
3
+ metadata.gz: f09e850b5f4ee0406c5686317145571fa0bc5e8158b0b39c5161bb9a3cbb3878
4
+ data.tar.gz: d839bbfa3ff4e7ef4a37501a46ce65c12425dc620ccbdf9aae174a059898aa84
5
5
  SHA512:
6
- metadata.gz: 3b21d6fa4b33c029a8b23a8ec437e70e2799e3f2bec27239d3cbfc5a1a4bb8cd82fc95309ad27d22243695298535b02687b0948218df1f7a1a0812242079e3b7
7
- data.tar.gz: 3dc9629b16a4d9f496cee61bc40396f6893bfe114666ba7554327cd052946719410e2f4e89a27388cea291fd7b5ba1bcd37c669aa1dfc7b64c48a6622bafb013
6
+ metadata.gz: dee1ec11e6ca9ca18f74fedf260f10e25e9c49efa3297ca2df02aab02efa6282464dd88f0f1f79e3529c8c56239749c72779d8bfb7fbf8508b40047470e4f6f6
7
+ data.tar.gz: c7b4d4e1d4cdf7f60707621a57cfdd6a622ef91f6d6724abd1b344fc18b59ab4271ee7536513417023c20c3f470cac73c94ff50675661162d6ec1e62df02cd70
data/CHANGELOG CHANGED
@@ -1,3 +1,7 @@
1
+ = 3.41.0 (2021-02-17)
2
+
3
+ * Improve view performance with :content option up to 3x by calling compiled template methods directly (jeremyevans)
4
+
1
5
  = 3.40.0 (2021-01-14)
2
6
 
3
7
  * Add freeze_template_caches! to the precompile_templates plugin, which ensures all templates are precompiled, and speeds up template access (jeremyevans)
@@ -0,0 +1,9 @@
1
+ = Improvements
2
+
3
+ * The performance of the render plugin's view method when passed the
4
+ :content option and no other options or arguments has been improved
5
+ by about 3x, by calling compiled template methods directly.
6
+
7
+ * The compiled template method for the layout is cleared when the
8
+ render plugin is loaded again, which can fix issues when it is
9
+ loaded with different options that affect the layout.
@@ -183,6 +183,7 @@ class Roda
183
183
  app.const_set(:RodaCompiledTemplates, compiled_templates_module)
184
184
  end
185
185
  opts[:template_method_cache] = orig_method_cache || (opts[:cache_class] || RodaCache).new
186
+ opts[:template_method_cache][:_roda_layout] = nil if opts[:template_method_cache][:_roda_layout]
186
187
  opts[:cache] = orig_cache || (opts[:cache_class] || RodaCache).new
187
188
 
188
189
  opts[:layout_opts] = (opts[:layout_opts] || {}).dup
@@ -415,10 +416,8 @@ class Roda
415
416
  # Render the given template. If there is a default layout
416
417
  # for the class, take the result of the template rendering
417
418
  # and render it inside the layout. See Render for details.
418
- def view(template, opts = (optimized_template = _cached_template_method(template); OPTS))
419
- if optimized_template
420
- content = send(optimized_template, OPTS)
421
-
419
+ def view(template, opts = (content = _optimized_view_content(template); OPTS))
420
+ if content
422
421
  # First, check if the optimized layout method has already been created,
423
422
  # and use it if so. This way avoids the extra conditional and local variable
424
423
  # assignments in the next section.
@@ -518,6 +517,16 @@ class Roda
518
517
  end
519
518
  end
520
519
  end
520
+
521
+ # Get the content for #view, or return nil to use the unoptimized approach. Only called if
522
+ # a single argument is passed to view.
523
+ def _optimized_view_content(template)
524
+ if optimized_template = _cached_template_method(template)
525
+ send(optimized_template, OPTS)
526
+ elsif template.is_a?(Hash) && template.length == 1
527
+ template[:content]
528
+ end
529
+ end
521
530
  else
522
531
  # :nocov:
523
532
  def _cached_template_method(_)
@@ -535,6 +544,10 @@ class Roda
535
544
  def _optimized_render_method_for_locals(_, _)
536
545
  nil
537
546
  end
547
+
548
+ def _optimized_view_content(template)
549
+ nil
550
+ end
538
551
  # :nocov:
539
552
  end
540
553
 
@@ -51,6 +51,10 @@ class Roda
51
51
  def _cached_template_method(template)
52
52
  nil
53
53
  end
54
+
55
+ def _optimized_view_content(template)
56
+ nil
57
+ end
54
58
  end
55
59
 
56
60
  def render_locals
data/lib/roda/version.rb CHANGED
@@ -4,7 +4,7 @@ class Roda
4
4
  RodaMajorVersion = 3
5
5
 
6
6
  # The minor version of Roda, updated for new feature releases of Roda.
7
- RodaMinorVersion = 40
7
+ RodaMinorVersion = 41
8
8
 
9
9
  # The patch version of Roda, updated only for bug fixes from the last
10
10
  # feature release.
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: roda
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.40.0
4
+ version: 3.41.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremy Evans
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-01-14 00:00:00.000000000 Z
11
+ date: 2021-02-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack
@@ -211,6 +211,7 @@ extra_rdoc_files:
211
211
  - doc/release_notes/3.39.0.txt
212
212
  - doc/release_notes/3.4.0.txt
213
213
  - doc/release_notes/3.40.0.txt
214
+ - doc/release_notes/3.41.0.txt
214
215
  - doc/release_notes/3.5.0.txt
215
216
  - doc/release_notes/3.6.0.txt
216
217
  - doc/release_notes/3.7.0.txt
@@ -258,6 +259,7 @@ files:
258
259
  - doc/release_notes/3.39.0.txt
259
260
  - doc/release_notes/3.4.0.txt
260
261
  - doc/release_notes/3.40.0.txt
262
+ - doc/release_notes/3.41.0.txt
261
263
  - doc/release_notes/3.5.0.txt
262
264
  - doc/release_notes/3.6.0.txt
263
265
  - doc/release_notes/3.7.0.txt