herb 0.11.2-arm-linux-gnu → 0.11.3-arm-linux-gnu

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.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/Makefile +2 -0
  3. data/config.yml +7 -8
  4. data/ext/herb/error_helpers.c +3 -3
  5. data/lib/herb/3.2/herb.so +0 -0
  6. data/lib/herb/3.3/herb.so +0 -0
  7. data/lib/herb/3.4/herb.so +0 -0
  8. data/lib/herb/4.0/herb.so +0 -0
  9. data/lib/herb/ast/erb_render_node.rb +6 -2
  10. data/lib/herb/cli.rb +7 -3
  11. data/lib/herb/dev/runner.rb +5 -2
  12. data/lib/herb/engine/compiler.rb +39 -4
  13. data/lib/herb/engine/slots/dynamics_compiler.rb +1 -1
  14. data/lib/herb/engine/slots/state_compiler.rb +9 -1
  15. data/lib/herb/engine/slots/state_overrides.rb +17 -3
  16. data/lib/herb/engine/slots/visitor.rb +37 -7
  17. data/lib/herb/engine.rb +11 -1
  18. data/lib/herb/errors.rb +7 -7
  19. data/lib/herb/version.rb +1 -1
  20. data/sig/herb/ast/erb_render_node.rbs +2 -0
  21. data/sig/herb/dev/runner.rbs +2 -2
  22. data/sig/herb/engine/compiler.rbs +9 -0
  23. data/sig/herb/engine/slots/state_compiler.rbs +3 -0
  24. data/sig/herb/engine/slots/state_overrides.rbs +11 -2
  25. data/sig/herb/engine/slots/visitor.rbs +7 -0
  26. data/sig/herb/engine.rbs +2 -0
  27. data/sig/herb/errors.rbs +2 -2
  28. data/sig/serialized_ast_errors.rbs +1 -1
  29. data/src/analyze/action_view/tag_helpers.c +23 -9
  30. data/src/analyze/analyze.c +17 -10
  31. data/src/analyze/render_nodes.c +189 -38
  32. data/src/diff/herb_diff_children.c +1 -1
  33. data/src/diff/herb_diff_nodes.c +1 -9
  34. data/src/diff/herb_hash_tree.c +1 -1
  35. data/src/errors.c +17 -22
  36. data/src/extract.c +47 -7
  37. data/src/include/errors.h +3 -3
  38. data/src/include/version.h +1 -1
  39. data/src/lexer/token.c +2 -2
  40. data/src/parser/dot_notation.c +15 -5
  41. data/src/parser.c +3 -1
  42. data/templates/src/diff/herb_diff_nodes.c.erb +1 -9
  43. data/templates/src/diff/herb_hash_tree.c.erb +1 -1
  44. data/templates/src/errors.c.erb +2 -2
  45. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5a6c04be55d58d77429a901b7ace442b56fde6ec44597aceb046d2e2824ffcc4
4
- data.tar.gz: 759e7e8164b93bc2adc4da4ba096213a02eabf422db6c2d42ca35d449383a499
3
+ metadata.gz: 8d282325b19ac39581dc73285f42176e1801502278457c3a2777670d9374e456
4
+ data.tar.gz: 6e810fb1d069a09270626e4e878e77d43aaec757a3d40fe4d4a6f92f16813c40
5
5
  SHA512:
6
- metadata.gz: 13718b26ce1db6ac30a9adb56331381dcee35858e8ef872d40641a465759e0c2774b1399616afe65a939aff2d41d85c812807339b27128d5a4d1c31c2b26ab4b
7
- data.tar.gz: d74c231aad23d7380cd1793dedb9d06dc2ee1f94488818a2d79312110f2b408fb508daa23d6c763173c23282dfd60ede7af3b59aacfdf9a2009e7968e7a601e5
6
+ metadata.gz: 3f4a13cd013df6212a69d5fbb076fa69b920de0843332bc631c675289e720b02a69645803883a41cd1f0ceb67d4d471ca23319bb920e09874214f81bd64eb5b0
7
+ data.tar.gz: 4b870495b683ae47660b25b45badf526c26af5820dfa900f76fbea66d28a53d12185c391bd0ad12637dd5882aff449059e4c3de2adca887c2fde01a31ed57253
data/Makefile CHANGED
@@ -159,3 +159,5 @@ clangd_config:
159
159
  .PHONY: wasm
160
160
  wasm:
161
161
  cd wasm && make
162
+
163
+ -include fuzz/fuzz.mk
data/config.yml CHANGED
@@ -482,7 +482,7 @@ errors:
482
482
 
483
483
  - name: "RenderAmbiguousLocalsError"
484
484
  message:
485
- template: "Did you mean `render partial: '%s', locals: { ... }`? Using `render '%s', locals: { ... }` passes a local variable named `locals` to the partial instead of setting the `locals:` option."
485
+ template: "Did you mean `render partial: %s, locals: { ... }`? Using `render %s, locals: { ... }` passes a local variable named `locals` to the partial instead of setting the `locals:` option."
486
486
  arguments:
487
487
  - "partial"
488
488
  - "partial"
@@ -493,17 +493,16 @@ errors:
493
493
 
494
494
  - name: "RenderMissingLocalsError"
495
495
  message:
496
- template: "Wrap `%s` in `locals: { ... }` when using `partial:`. Use `render partial: '%s', locals: { %s }` instead. Without `locals:`, these keyword arguments are ignored."
496
+ template: "Wrap `%s` in `locals: { ... }` when using `partial:`. Use `render %s` instead. Without `locals:`, these keyword arguments are ignored."
497
497
  arguments:
498
498
  - "keywords"
499
- - "partial"
500
- - "keywords"
499
+ - "suggestion"
501
500
 
502
501
  fields:
503
- - name: "partial"
502
+ - name: "keywords"
504
503
  type: "string"
505
504
 
506
- - name: "keywords"
505
+ - name: "suggestion"
507
506
  type: "string"
508
507
 
509
508
  - name: "RenderNoArgumentsError"
@@ -515,7 +514,7 @@ errors:
515
514
 
516
515
  - name: "RenderConflictingPartialError"
517
516
  message:
518
- template: "Both a positional partial `'%s'` and a keyword `partial: '%s'` were passed to `render`. Use one form or the other, not both."
517
+ template: "Both a positional partial `%s` and a keyword `partial: %s` were passed to `render`. Use one form or the other, not both."
519
518
  arguments:
520
519
  - "positional_partial"
521
520
  - "keyword_partial"
@@ -546,7 +545,7 @@ errors:
546
545
 
547
546
  - name: "RenderLayoutWithoutBlockError"
548
547
  message:
549
- template: "Layout rendering needs a block. Use `render layout: '%s' do ... end` so the layout has content to wrap."
548
+ template: "Layout rendering needs a block. Use `render layout: %s do ... end` so the layout has content to wrap."
550
549
  arguments:
551
550
  - "layout"
552
551
 
@@ -882,15 +882,15 @@ static VALUE rb_render_missing_locals_error_from_c_struct(RENDER_MISSING_LOCALS_
882
882
  VALUE location = rb_location_from_c_struct(error->location);
883
883
  VALUE message = rb_string_from_hb_string(error->message);
884
884
 
885
- VALUE render_missing_locals_error_partial = rb_utf8_str_new(render_missing_locals_error->partial.data, render_missing_locals_error->partial.length);
886
885
  VALUE render_missing_locals_error_keywords = rb_utf8_str_new(render_missing_locals_error->keywords.data, render_missing_locals_error->keywords.length);
886
+ VALUE render_missing_locals_error_suggestion = rb_utf8_str_new(render_missing_locals_error->suggestion.data, render_missing_locals_error->suggestion.length);
887
887
 
888
888
  VALUE args[5] = {
889
889
  type,
890
890
  location,
891
891
  message,
892
- render_missing_locals_error_partial,
893
- render_missing_locals_error_keywords
892
+ render_missing_locals_error_keywords,
893
+ render_missing_locals_error_suggestion
894
894
  };
895
895
 
896
896
  return rb_class_new_instance(5, args, cRenderMissingLocalsError);
data/lib/herb/3.2/herb.so CHANGED
Binary file
data/lib/herb/3.3/herb.so CHANGED
Binary file
data/lib/herb/3.4/herb.so CHANGED
Binary file
data/lib/herb/4.0/herb.so CHANGED
Binary file
@@ -8,11 +8,15 @@ module Herb
8
8
  module AST
9
9
  class ERBRenderNode < Node
10
10
  def static_partial?
11
- keywords&.partial && !keywords&.partial&.value&.empty?
11
+ keywords&.partial && !keywords&.partial&.value&.empty? && !interpolated_partial?
12
+ end
13
+
14
+ def interpolated_partial?
15
+ keywords&.partial&.value&.start_with?('"', "'", "%", "<<") || false
12
16
  end
13
17
 
14
18
  def dynamic?
15
- !static_partial? && (keywords&.object || keywords&.renderable)
19
+ interpolated_partial? || (!static_partial? && (keywords&.object || keywords&.renderable))
16
20
  end
17
21
 
18
22
  def partial_path
data/lib/herb/cli.rb CHANGED
@@ -13,7 +13,7 @@ require_relative "engine/slots/visitor"
13
13
  class Herb::CLI
14
14
  include Herb::Colors
15
15
 
16
- attr_accessor :json, :silent, :log_file, :no_timing, :local, :escape, :no_escape, :freeze, :debug, :tool, :strict, :analyze, :track_whitespace, :track_locations, :verbose, :isolate, :arena_stats, :leak_check, :action_view_helpers, :no_trim, :optimize, :slots, :scoped_styles, :inline_css, :file_timeout
16
+ attr_accessor :json, :silent, :log_file, :no_timing, :local, :escape, :no_escape, :freeze, :debug, :tool, :strict, :analyze, :track_whitespace, :track_locations, :verbose, :isolate, :arena_stats, :leak_check, :action_view_helpers, :no_trim, :optimize, :slots, :scoped_styles, :inline_css, :file_timeout, :port
17
17
 
18
18
  def initialize(args)
19
19
  @args = args
@@ -283,6 +283,10 @@ class Herb::CLI
283
283
  self.no_timing = true
284
284
  end
285
285
 
286
+ parser.on("--port PORT", Integer, "Port for the dev server (for dev command)") do |port|
287
+ self.port = port
288
+ end
289
+
286
290
  parser.on("--local", "Use localhost for playground command instead of herb-tools.dev") do
287
291
  self.local = true
288
292
  end
@@ -1061,7 +1065,7 @@ class Herb::CLI
1061
1065
 
1062
1066
  def dev_restart
1063
1067
  require_relative "dev/runner"
1064
- Herb::Dev::Runner.new(path: @file || ".").restart
1068
+ Herb::Dev::Runner.new(path: @file || ".", port: port).restart
1065
1069
  end
1066
1070
 
1067
1071
  def dev_status
@@ -1071,7 +1075,7 @@ class Herb::CLI
1071
1075
 
1072
1076
  def run_dev_server
1073
1077
  require_relative "dev/runner"
1074
- Herb::Dev::Runner.new(path: @file || ".").run
1078
+ Herb::Dev::Runner.new(path: @file || ".", port: port).run
1075
1079
  end
1076
1080
 
1077
1081
  def diff_files
@@ -23,9 +23,10 @@ module Herb
23
23
  HIDE_CURSOR = "\e[?25l" #: String
24
24
  SHOW_CURSOR = "\e[?25h" #: String
25
25
 
26
- #: (?path: String) -> void
27
- def initialize(path: ".")
26
+ #: (?path: String, ?port: Integer?) -> void
27
+ def initialize(path: ".", port: nil)
28
28
  @path = path
29
+ @port = port
29
30
  end
30
31
 
31
32
  #: () -> void
@@ -214,6 +215,8 @@ module Herb
214
215
 
215
216
  #: () -> Integer
216
217
  def find_port
218
+ return @port if @port
219
+
217
220
  port = Herb::Dev::Server::DEFAULT_PORT
218
221
  port_owner = Herb::Dev::ServerEntry.find_by_port(port)
219
222
 
@@ -61,8 +61,14 @@ module Herb
61
61
  @engine.send(:add_expression, indicator, value)
62
62
  end
63
63
  when :expr_block, :expr_block_escaped
64
- @engine.send(:add_expression_block, indicator_for(type), value)
64
+ if context_aware_context?(context)
65
+ @engine.send(:add_context_aware_expression_block, indicator_for(type), value, context)
66
+ else
67
+ @engine.send(:add_expression_block, indicator_for(type), value)
68
+ end
65
69
  when :expr_block_end
70
+ escaped = true if context_escaped?(context)
71
+
66
72
  @engine.send(:add_expression_block_end, value, escaped: escaped)
67
73
  when :chain
68
74
  @engine.send(:add_expression_result, value)
@@ -134,13 +140,38 @@ module Herb
134
140
  def visit_html_attribute_value_node(node)
135
141
  push_context(:attribute_value)
136
142
 
137
- add_text(node.open_quote&.value || '"') if node.quoted
138
- visit_all(node.children)
139
- add_text(node.close_quote&.value || '"') if node.quoted
143
+ if node.quoted
144
+ add_text(node.open_quote&.value || '"')
145
+ visit_all(node.children)
146
+ add_text(node.close_quote&.value || '"')
147
+ elsif attribute_escaping? && contains_erb_output?(node)
148
+ add_text('"')
149
+ visit_all(node.children)
150
+ add_text('"')
151
+ else
152
+ visit_all(node.children)
153
+ end
140
154
 
141
155
  pop_context
142
156
  end
143
157
 
158
+ def attribute_escaping?
159
+ escapefunc = @engine.send(:context_escape_function, :attribute_value)
160
+
161
+ !escapefunc.nil? && !escapefunc.empty?
162
+ end
163
+
164
+ def contains_erb_output?(node)
165
+ node.compact_child_nodes.any? { |child| erb_output_node?(child) || contains_erb_output?(child) }
166
+ end
167
+
168
+ #: (untyped) -> bool
169
+ def erb_output_node?(node)
170
+ return false unless node.respond_to?(:tag_opening)
171
+
172
+ node.tag_opening&.value&.start_with?("<%=") || false
173
+ end
174
+
144
175
  def visit_erb_open_tag_node(node)
145
176
  tag_name = node.tag_name&.value
146
177
 
@@ -702,6 +733,10 @@ module Herb
702
733
  [:attribute_value, :script_content, :style_content].include?(context)
703
734
  end
704
735
 
736
+ def context_escaped?(context)
737
+ context_aware_context?(context) && !@engine.send(:context_escape_function, context).nil?
738
+ end
739
+
705
740
  def should_escape_output?(opening)
706
741
  is_double_equals = opening == "<%=="
707
742
  is_double_equals ? !@escape : @escape
@@ -131,7 +131,7 @@ module Herb
131
131
  SCOPE_BUFFER = "__herb_scope" #: String
132
132
  ITEMS_BUFFER = "__herb_items" #: String
133
133
  KEY_BUFFER = "__herb_key" #: String
134
- OCCURRENCE_BUFFER = "__herb_occurrence" #: String
134
+ OCCURRENCE_BUFFER = Visitor::VALUES_OCCURRENCE #: String
135
135
  RENDERED_BUFFER = "__herb_rendered" #: String
136
136
 
137
137
  BRANCHING_NODES = [
@@ -732,7 +732,15 @@ module Herb
732
732
 
733
733
  #: () -> String
734
734
  def overrides_prelude
735
- "#{OVERRIDES_LOCAL} = ::Herb::Engine::Slots::StateOverrides.resolve((#{StateOverrides::HOOK} if defined?(#{StateOverrides::HOOK})), #{@visitor.identifier.inspect})"
735
+ "#{OVERRIDES_LOCAL} = ::Herb::Engine::Slots::StateOverrides.resolve((#{StateOverrides::HOOK} if defined?(#{StateOverrides::HOOK})), #{@visitor.identifier.inspect}, #{occurrence_reference})"
736
+ end
737
+
738
+ #: () -> String
739
+ def occurrence_reference
740
+ rendered = Visitor::OCCURRENCE
741
+ values = Visitor::VALUES_OCCURRENCE
742
+
743
+ "(defined?(#{rendered}) ? #{rendered} : defined?(#{values}) ? #{values} : 0)"
736
744
  end
737
745
 
738
746
  #: () -> void
@@ -20,11 +20,16 @@ module Herb
20
20
  # has written the state since it was seeded knows better. A binding sits over them, since
21
21
  # the client cannot tell two render sites of one partial apart.
22
22
  #
23
+ # A template rendered more than once on a page sends the first copy's values at the top level
24
+ # and every later copy that differs under `@occurrences`, keyed by its render occurrence. A
25
+ # copy's own values layer over the first copy's.
26
+ #
23
27
  module StateOverrides
24
28
  HOOK = "__herb_state_overrides" #: String
29
+ OCCURRENCES = "@occurrences" #: String
25
30
 
26
- #: (untyped, String) -> Hash[String, untyped]?
27
- def self.resolve(raw, identifier)
31
+ #: (untyped, String, ?Integer) -> Hash[String, untyped]?
32
+ def self.resolve(raw, identifier, occurrence = 0)
28
33
  frame = Bindings.current(identifier)
29
34
  sent = raw.is_a?(Hash) ? raw[identifier] : nil
30
35
 
@@ -33,12 +38,21 @@ module Herb
33
38
  layered = {} #: Hash[String, untyped]
34
39
 
35
40
  layered.merge!(frame.fetch(:seeded)) if frame
36
- layered.merge!(sent) if sent.is_a?(Hash)
41
+ layered.merge!(sent_for(sent, occurrence)) if sent.is_a?(Hash)
37
42
  layered.merge!(frame.fetch(:bound)) if frame
38
43
 
39
44
  layered
40
45
  end
41
46
 
47
+ #: (Hash[untyped, untyped], Integer) -> Hash[untyped, untyped]
48
+ def self.sent_for(sent, occurrence)
49
+ occurrences = sent[OCCURRENCES]
50
+ own = occurrences.is_a?(Hash) ? occurrences[occurrence.to_s] : nil
51
+ shared = sent.except(OCCURRENCES)
52
+
53
+ own.is_a?(Hash) ? shared.merge(own) : shared
54
+ end
55
+
42
56
  #: (Hash[String, untyped]?, String, Symbol) { () -> untyped } -> untyped
43
57
  def self.fetch(overrides, name, kind)
44
58
  return yield if overrides.nil? || !overrides.key?(name)
@@ -66,6 +66,7 @@ module Herb
66
66
  COVERED = "@_herb_covered" #: String
67
67
  OCCURRENCES = "@_herb_region_occurrences" #: String
68
68
  OCCURRENCE = "_herb_occurrence" #: String
69
+ VALUES_OCCURRENCE = "__herb_occurrence" #: String
69
70
  POSITION = "__herb_position" #: String
70
71
  NAME_ATTRIBUTE = "data-herb-name" #: String
71
72
  KEY_ATTRIBUTE = "herb-key" #: String
@@ -694,6 +695,7 @@ module Herb
694
695
 
695
696
  @static_markup = Statics.new(@standing, @element_anchored).markup(node.children) if @capture_static_markup
696
697
 
698
+ hold_trailing_newline(node) if client?
697
699
  wrap_region(node)
698
700
  append_statics(node)
699
701
  deliver_manifest(node)
@@ -1194,6 +1196,33 @@ module Herb
1194
1196
  Herb::AST::HTMLTextNode.build(content: content.dup)
1195
1197
  end
1196
1198
 
1199
+ def raw_text_node(text)
1200
+ erb_code_node("#{@bufvar} << ::Herb::Engine.raw(#{text.gsub("\r\n", "\n").inspect})")
1201
+ end
1202
+
1203
+ #: (Herb::AST::DocumentNode) -> void
1204
+ def hold_trailing_newline(document_node)
1205
+ last = document_node.children.last
1206
+ return unless last.is_a?(Herb::AST::HTMLTextNode)
1207
+
1208
+ content = last.content.to_s
1209
+ newline = content[/(?:\r?\n)+\z/]
1210
+ return unless newline
1211
+
1212
+ trimmed = content.delete_suffix(newline)
1213
+ previous = document_node.children[-2]
1214
+
1215
+ return if trimmed.match?(/\A[ \t]*\z/) && erb_node?(previous) && !erb_output?(erb_opening(previous))
1216
+
1217
+ if trimmed.empty?
1218
+ document_node.children.pop
1219
+ else
1220
+ document_node.children[-1] = text_node(trimmed)
1221
+ end
1222
+
1223
+ document_node.children.push(erb_code_node("#{@bufvar} << #{newline.gsub("\r\n", "\n").inspect}.freeze"))
1224
+ end
1225
+
1197
1226
  def erb_code_node(code)
1198
1227
  Herb::AST::ERBContentNode.build(
1199
1228
  tag_opening: token(:erb_start, "<%"),
@@ -1980,25 +2009,26 @@ module Herb
1980
2009
 
1981
2010
  return if entries.empty?
1982
2011
 
1983
- seen = entries.map { |key, _| "#{COVERED}[#{covered_key(key).inspect}]" }.join(" && ")
2012
+ references = entries.map { |key, _| "#{COVERED}[#{covered_key(key).inspect}]" }
1984
2013
 
1985
2014
  nodes = [
1986
- erb_code_node("unless #{seen}"),
2015
+ erb_code_node("unless #{references.join(" && ")}"),
1987
2016
  text_node(@markers.statics_open(identifier, version))
1988
2017
  ] #: Array[Herb::AST::Node]
1989
2018
 
1990
- entries.each do |key, parked|
1991
- reference = "#{COVERED}[#{covered_key(key).inspect}]"
2019
+ guarded = entries.size > 1
1992
2020
 
1993
- nodes.push(erb_code_node("unless #{reference}"))
2021
+ entries.zip(references).each do |(_, parked), reference|
2022
+ nodes.push(erb_code_node("unless #{reference}")) if guarded
1994
2023
 
1995
2024
  if parked.is_a?(String)
1996
- nodes.push(text_node(parked))
2025
+ nodes.push(raw_text_node(parked))
1997
2026
  else
1998
2027
  nodes.concat(parked)
1999
2028
  end
2000
2029
 
2001
- nodes.push(erb_code_node("#{reference} = true"), erb_code_node("end"))
2030
+ nodes.push(erb_code_node("#{reference} = true"))
2031
+ nodes.push(erb_code_node("end")) if guarded
2002
2032
  end
2003
2033
 
2004
2034
  nodes.push(text_node(@markers.statics_close), erb_code_node("end"))
data/lib/herb/engine.rb CHANGED
@@ -175,7 +175,7 @@ module Herb
175
175
  end
176
176
 
177
177
  def self.js(value)
178
- value.to_s.gsub(/[\\'"<>&\n\r\t\f\b]/) do |char|
178
+ value.to_s.gsub(/[\\'"`$<>&\n\r\t\f\b]/) do |char|
179
179
  case char
180
180
  when "\n" then "\\n"
181
181
  when "\r" then "\\r"
@@ -257,6 +257,16 @@ module Herb
257
257
  end
258
258
  end
259
259
 
260
+ def add_context_aware_expression_block(indicator, code, context)
261
+ escapefunc = context_escape_function(context)
262
+
263
+ return add_expression_block(indicator, code) if escapefunc.nil?
264
+
265
+ @_expression_block_open_paren = true
266
+
267
+ with_buffer { @src << " << #{escapefunc}((" << code << trailing_newline(code) }
268
+ end
269
+
260
270
  def context_escape_function(context)
261
271
  case context
262
272
  when :attribute_value then @attrfunc
data/lib/herb/errors.rb CHANGED
@@ -1449,14 +1449,14 @@ module Herb
1449
1449
  class RenderMissingLocalsError < Error
1450
1450
  include Colors
1451
1451
 
1452
- attr_reader :partial #: String?
1453
1452
  attr_reader :keywords #: String?
1453
+ attr_reader :suggestion #: String?
1454
1454
 
1455
1455
  #: (String, Location?, String, String, String) -> void
1456
- def initialize(type, location, message, partial, keywords)
1456
+ def initialize(type, location, message, keywords, suggestion)
1457
1457
  super(type, location, message)
1458
- @partial = partial
1459
1458
  @keywords = keywords
1459
+ @suggestion = suggestion
1460
1460
  end
1461
1461
 
1462
1462
  #: () -> String
@@ -1467,8 +1467,8 @@ module Herb
1467
1467
  #: () -> serialized_render_missing_locals_error
1468
1468
  def to_hash
1469
1469
  super.merge(
1470
- partial: partial,
1471
- keywords: keywords
1470
+ keywords: keywords,
1471
+ suggestion: suggestion
1472
1472
  ) #: Herb::serialized_render_missing_locals_error
1473
1473
  end
1474
1474
 
@@ -1478,8 +1478,8 @@ module Herb
1478
1478
 
1479
1479
  output += white("@ #{bold(red(error_name))} #{dimmed("(location: #{location&.tree_inspect || "∅"})\n")}")
1480
1480
  output += white("├── message: #{green(message.inspect)}\n")
1481
- output += white("├── partial: #{green(partial.inspect)}\n")
1482
- output += white("└── keywords: #{green(keywords.inspect)}\n")
1481
+ output += white("├── keywords: #{green(keywords.inspect)}\n")
1482
+ output += white("└── suggestion: #{green(suggestion.inspect)}\n")
1483
1483
  output += %(\n)
1484
1484
 
1485
1485
  output.gsub(/^/, " " * indent)
data/lib/herb/version.rb CHANGED
@@ -2,5 +2,5 @@
2
2
  # typed: true
3
3
 
4
4
  module Herb
5
- VERSION = "0.11.2"
5
+ VERSION = "0.11.3"
6
6
  end
@@ -5,6 +5,8 @@ module Herb
5
5
  class ERBRenderNode < Node
6
6
  def static_partial?: () -> untyped
7
7
 
8
+ def interpolated_partial?: () -> untyped
9
+
8
10
  def dynamic?: () -> untyped
9
11
 
10
12
  def partial_path: () -> untyped
@@ -16,8 +16,8 @@ module Herb
16
16
 
17
17
  SHOW_CURSOR: String
18
18
 
19
- # : (?path: String) -> void
20
- def initialize: (?path: String) -> void
19
+ # : (?path: String, ?port: Integer?) -> void
20
+ def initialize: (?path: String, ?port: Integer?) -> void
21
21
 
22
22
  # : () -> void
23
23
  def run: () -> void
@@ -35,6 +35,13 @@ module Herb
35
35
 
36
36
  def visit_html_attribute_value_node: (untyped node) -> untyped
37
37
 
38
+ def attribute_escaping?: () -> untyped
39
+
40
+ def contains_erb_output?: (untyped node) -> untyped
41
+
42
+ # : (untyped) -> bool
43
+ def erb_output_node?: (untyped) -> bool
44
+
38
45
  def visit_erb_open_tag_node: (untyped node) -> untyped
39
46
 
40
47
  def visit_html_virtual_close_tag_node: (untyped node) -> untyped
@@ -153,6 +160,8 @@ module Herb
153
160
 
154
161
  def context_aware_context?: (untyped context) -> untyped
155
162
 
163
+ def context_escaped?: (untyped context) -> untyped
164
+
156
165
  def should_escape_output?: (untyped opening) -> untyped
157
166
 
158
167
  def add_expression_with_escaping: (untyped code, untyped should_escape) -> untyped
@@ -166,6 +166,9 @@ module Herb
166
166
  # : () -> String
167
167
  def overrides_prelude: () -> String
168
168
 
169
+ # : () -> String
170
+ def occurrence_reference: () -> String
171
+
169
172
  # : () -> void
170
173
  def classify_state_conditionals: () -> void
171
174
 
@@ -16,11 +16,20 @@ module Herb
16
16
  # the frame layers with the client's values. A seed sits under them, since a client that
17
17
  # has written the state since it was seeded knows better. A binding sits over them, since
18
18
  # the client cannot tell two render sites of one partial apart.
19
+ #
20
+ # A template rendered more than once on a page sends the first copy's values at the top level
21
+ # and every later copy that differs under `@occurrences`, keyed by its render occurrence. A
22
+ # copy's own values layer over the first copy's.
19
23
  module StateOverrides
20
24
  HOOK: String
21
25
 
22
- # : (untyped, String) -> Hash[String, untyped]?
23
- def self.resolve: (untyped, String) -> Hash[String, untyped]?
26
+ OCCURRENCES: String
27
+
28
+ # : (untyped, String, ?Integer) -> Hash[String, untyped]?
29
+ def self.resolve: (untyped, String, ?Integer) -> Hash[String, untyped]?
30
+
31
+ # : (Hash[untyped, untyped], Integer) -> Hash[untyped, untyped]
32
+ def self.sent_for: (Hash[untyped, untyped], Integer) -> Hash[untyped, untyped]
24
33
 
25
34
  # : (Hash[String, untyped]?, String, Symbol) { () -> untyped } -> untyped
26
35
  def self.fetch: (Hash[String, untyped]?, String, Symbol) { () -> untyped } -> untyped
@@ -57,6 +57,8 @@ module Herb
57
57
 
58
58
  OCCURRENCE: String
59
59
 
60
+ VALUES_OCCURRENCE: String
61
+
60
62
  POSITION: String
61
63
 
62
64
  NAME_ATTRIBUTE: String
@@ -411,6 +413,11 @@ module Herb
411
413
 
412
414
  def text_node: (untyped content) -> untyped
413
415
 
416
+ def raw_text_node: (untyped text) -> untyped
417
+
418
+ # : (Herb::AST::DocumentNode) -> void
419
+ def hold_trailing_newline: (Herb::AST::DocumentNode) -> void
420
+
414
421
  def erb_code_node: (untyped code) -> untyped
415
422
 
416
423
  def erb_output_node: (untyped code) -> untyped
data/sig/herb/engine.rbs CHANGED
@@ -59,6 +59,8 @@ module Herb
59
59
 
60
60
  def add_context_aware_expression: (untyped indicator, untyped code, untyped context) -> untyped
61
61
 
62
+ def add_context_aware_expression_block: (untyped indicator, untyped code, untyped context) -> untyped
63
+
62
64
  def context_escape_function: (untyped context) -> untyped
63
65
 
64
66
  def add_expression_result: (untyped code) -> untyped
data/sig/herb/errors.rbs CHANGED
@@ -707,10 +707,10 @@ module Herb
707
707
  class RenderMissingLocalsError < Error
708
708
  include Colors
709
709
 
710
- attr_reader partial: String?
711
-
712
710
  attr_reader keywords: String?
713
711
 
712
+ attr_reader suggestion: String?
713
+
714
714
  # : (String, Location?, String, String, String) -> void
715
715
  def initialize: (String, Location?, String, String, String) -> void
716
716
 
@@ -158,8 +158,8 @@ module Herb
158
158
  }
159
159
 
160
160
  type serialized_render_missing_locals_error = serialized_error & {
161
- partial: String,
162
161
  keywords: String,
162
+ suggestion: String,
163
163
  }
164
164
 
165
165
  type serialized_render_no_arguments_error = serialized_error & {