homura-runtime 0.2.18 → 0.2.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1bd6f3a366405aeb0ba2673c4827c7d34d8bef757d9194c64e71ca881bfe821f
4
- data.tar.gz: 1ccc18ce83b42969bac914ecda37c21cdbfe79fd86971a1de1df1b25c3014302
3
+ metadata.gz: c353eae6d02619f499bf359610f28d12c0824415cc584e835dd0440d6807cff6
4
+ data.tar.gz: 998317164a89b71d98f01275a20dd1482d7ccf464c8ebef1095555db669765be
5
5
  SHA512:
6
- metadata.gz: 777ce1497af06f6a5168bef5e195576fcdbd216a7da25b5d0eda657fea4757f074fb48f873f28eb3f6c5854c5ce98bf1f01dfa870b31a067eab93ef7dd8b9dce
7
- data.tar.gz: 6a9e88cbfea6b27e46dc35c1bdb24bc02cdba8899839066d9d547057e18d9d67a319fdabed88a4ad36f852af49fd97bf41ef3aad964b720333bdd29c5c1438f6
6
+ metadata.gz: f6b0a9a1f4d55913deb468056980e70c3913ef7397603f1b9ee156241cf6d55cdd7eb6cb94cf54513c1d293816a9f69d455e36731f013c648a4716bec49f0972
7
+ data.tar.gz: 19e6c31d9e1fee24749b91a8d3caadb6789d9d05652d76ce2addc9642b892d47ac8fa8fffad7ff9862d309c34d994af9cc5da718b20d6b96bb2e38ce7e492d74
data/exe/compile-erb CHANGED
@@ -415,6 +415,25 @@ def emit_sinatra_patch(io, namespace)
415
415
  end
416
416
  end
417
417
 
418
+ # A template is "layout-like" if its name is `:layout` or starts
419
+ # with `layout_` (e.g. `:layout_docs`). The auto-layout pass in
420
+ # `erb` skips wrapping such templates in `:layout` so that
421
+ # rendering `:layout_docs` doesn't end up nested inside `:layout`,
422
+ # which would otherwise produce a duplicate header / nav.
423
+ def __homura_layout_template?(template)
424
+ name = template.to_sym
425
+ name == :layout || name.to_s.start_with?('layout_')
426
+ end
427
+
428
+ # Rails-/Sinatra-flavoured partial convention: a template name
429
+ # starting with `_` is treated as a partial (e.g. `_docs_nav`),
430
+ # so the auto-layout pass leaves it alone. Without this, calling
431
+ # `<%= erb :_docs_nav %>` from inside a layout template would
432
+ # rewrap the partial in `:layout`, doubling header/nav output.
433
+ def __homura_partial_template?(template)
434
+ template.to_s.start_with?('_')
435
+ end
436
+
418
437
  # homura patch: dispatch to precompiled templates when we
419
438
  # have one. Unknown symbols raise a clear message instead of
420
439
  # wandering into upstream Tilt, which would blow up on
@@ -432,7 +451,10 @@ def emit_sinatra_patch(io, namespace)
432
451
 
433
452
  layout = options[:layout]
434
453
  layout = false if layout.nil? && options.include?(:layout)
435
- if layout.nil? && template.to_sym != :layout && ::#{namespace}.registered?(:layout)
454
+ if layout.nil? &&
455
+ !__homura_layout_template?(template) &&
456
+ !__homura_partial_template?(template) &&
457
+ ::#{namespace}.registered?(:layout)
436
458
  layout = :layout
437
459
  end
438
460
  if layout
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CloudflareWorkers
4
- VERSION = '0.2.18'
4
+ VERSION = '0.2.20'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: homura-runtime
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.18
4
+ version: 0.2.20
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kazuhiro Homma