homura-runtime 0.2.19 → 0.2.21

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: 94e4ec7af2878bc59ebedd0ebe8841d5852b4fb35d736d713a62ce1ef1bb1cfb
4
- data.tar.gz: 6f21d253588daa097a1541ddd017b58a28b10c38ccc703f2a3ee9e6c650f490f
3
+ metadata.gz: 0abbf529c5ccbf21c28d4f6106d3b0d90dcc12d5c5d05ddc9ef1dcdad78b84fb
4
+ data.tar.gz: 0f82648388b2082293eefdd500cc0513c6c81d02cc13f42f27333b52d203407c
5
5
  SHA512:
6
- metadata.gz: dd0b2cb20babf2fe3cb57167dfdc509fef69ccd5d141cf44c0a370b9e8aca29425267433eb4fdf002b0e081583c8028deb1799d4e8c53e808a2b175f2a611c7e
7
- data.tar.gz: d794586f918cef8b0cabebec3923525078c69a9b68e75e0da96096ffa8afdc02aceb6cd277b07f8b15c0396a3f6f6b6ecf77e2c0c9308cd27624acce320b45ad
6
+ metadata.gz: d2360a1809e4373c4133a1ee5225d3dad880b5570b492c8db5a1640790388d2cfaadeba699ad10fce8f3e350a24f0ad361bc3acb20d48c8ff6379dc170a54ad8
7
+ data.tar.gz: 268fe0b01b20ab7c7d0da2c0d930d9d31d1e9da6c1968a52ca4ae49bfc9d04f9cb70307d302978162d50c6c762a5e2565d153805cf0b9211ccadb7942956d88b
data/exe/compile-erb CHANGED
@@ -425,6 +425,15 @@ def emit_sinatra_patch(io, namespace)
425
425
  name == :layout || name.to_s.start_with?('layout_')
426
426
  end
427
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
+
428
437
  # homura patch: dispatch to precompiled templates when we
429
438
  # have one. Unknown symbols raise a clear message instead of
430
439
  # wandering into upstream Tilt, which would blow up on
@@ -442,7 +451,10 @@ def emit_sinatra_patch(io, namespace)
442
451
 
443
452
  layout = options[:layout]
444
453
  layout = false if layout.nil? && options.include?(:layout)
445
- if layout.nil? && !__homura_layout_template?(template) && ::#{namespace}.registered?(:layout)
454
+ if layout.nil? &&
455
+ !__homura_layout_template?(template) &&
456
+ !__homura_partial_template?(template) &&
457
+ ::#{namespace}.registered?(:layout)
446
458
  layout = :layout
447
459
  end
448
460
  if layout
@@ -500,14 +512,18 @@ inputs =
500
512
 
501
513
  template_root = positional.find { |a| File.directory?(a) } || options[:input_dir]
502
514
 
503
- if inputs.empty?
504
- warn "bin/compile-erb: no .erb files found (under #{options[:input_dir]}/ or from args)"
505
- exit 1
506
- end
507
-
508
515
  write_file = !options[:stdout] && (positional.empty? || options[:output])
509
516
  out_path = options[:output]
510
517
 
518
+ # An app with zero ERB templates (e.g. an example that builds HTML
519
+ # inline with Ruby heredocs) is a valid case: still emit the registry
520
+ # header + Sinatra dispatcher patch so `erb :foo` raises a clear error
521
+ # at runtime instead of silently disappearing, and so the build
522
+ # pipeline doesn't fail when there is nothing to compile.
523
+ if inputs.empty?
524
+ warn "compile-erb: no .erb files under #{options[:input_dir]}/ — writing empty registry"
525
+ end
526
+
511
527
  if write_file
512
528
  FileUtils.mkdir_p(File.dirname(out_path))
513
529
  File.open(out_path, 'w') do |io|
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CloudflareWorkers
4
- VERSION = '0.2.19'
4
+ VERSION = '0.2.21'
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.19
4
+ version: 0.2.21
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kazuhiro Homma