curlybars 1.16.1.pre.3 → 1.17.0.pre

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 (50) hide show
  1. checksums.yaml +4 -4
  2. data/exe/curlybars-indent-lint +2 -0
  3. data/lib/curlybars/configuration.rb +5 -1
  4. data/lib/curlybars/dependency_tracker.rb +2 -0
  5. data/lib/curlybars/error/base.rb +2 -0
  6. data/lib/curlybars/error/compile.rb +2 -0
  7. data/lib/curlybars/error/lex.rb +2 -0
  8. data/lib/curlybars/error/parse.rb +4 -0
  9. data/lib/curlybars/error/presenter/not_found.rb +2 -0
  10. data/lib/curlybars/error/render.rb +2 -0
  11. data/lib/curlybars/error/validate.rb +2 -0
  12. data/lib/curlybars/generic.rb +2 -0
  13. data/lib/curlybars/lexer.rb +159 -53
  14. data/lib/curlybars/method_whitelist.rb +2 -0
  15. data/lib/curlybars/node/block_helper_else.rb +2 -0
  16. data/lib/curlybars/node/each_else.rb +3 -0
  17. data/lib/curlybars/node/if_else.rb +2 -0
  18. data/lib/curlybars/node/item.rb +2 -0
  19. data/lib/curlybars/node/literal.rb +2 -0
  20. data/lib/curlybars/node/option.rb +2 -0
  21. data/lib/curlybars/node/output.rb +2 -0
  22. data/lib/curlybars/node/partial.rb +2 -0
  23. data/lib/curlybars/node/path.rb +2 -5
  24. data/lib/curlybars/node/root.rb +2 -0
  25. data/lib/curlybars/node/sub_expression.rb +10 -11
  26. data/lib/curlybars/node/template.rb +2 -5
  27. data/lib/curlybars/node/text.rb +2 -0
  28. data/lib/curlybars/node/unless_else.rb +2 -0
  29. data/lib/curlybars/node/variable.rb +2 -0
  30. data/lib/curlybars/node/with_else.rb +3 -0
  31. data/lib/curlybars/parser.rb +247 -146
  32. data/lib/curlybars/partial_presenter.rb +2 -0
  33. data/lib/curlybars/path_finder.rb +3 -2
  34. data/lib/curlybars/position.rb +2 -0
  35. data/lib/curlybars/presenter.rb +2 -0
  36. data/lib/curlybars/processor/token_factory.rb +3 -1
  37. data/lib/curlybars/railtie.rb +2 -0
  38. data/lib/curlybars/rendering_support.rb +16 -1
  39. data/lib/curlybars/safe_buffer.rb +2 -0
  40. data/lib/curlybars/serialization_guard.rb +2 -0
  41. data/lib/curlybars/template_handler.rb +2 -0
  42. data/lib/curlybars/token.rb +28 -0
  43. data/lib/curlybars/validation_context.rb +2 -0
  44. data/lib/curlybars/version.rb +1 -1
  45. data/lib/curlybars/visitor.rb +2 -0
  46. data/lib/curlybars.rb +16 -10
  47. metadata +3 -33
  48. data/lib/curlybars/node/boolean.rb +0 -24
  49. data/lib/curlybars/node/string.rb +0 -24
  50. data/lib/curlybars/processor/tilde.rb +0 -34
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e8152eb9d4e5789fce89e656283b0ae7be78799bafcd9755c99d793674a01d9a
4
- data.tar.gz: 57102435a47d352a31c16d994e36bd61436b777e0e98409355bc31161045a44d
3
+ metadata.gz: f6da5518b6b73d9f76f01132039228b8eeb4e7ca2e47fb6148dcdb05bbac949d
4
+ data.tar.gz: '0688645c6e1f342ca1529b64b7797e48f0ffc27f697a73b717bcb1e222bb0ba7'
5
5
  SHA512:
6
- metadata.gz: 797b775e410fff90804ecfad939a0f31add15dc199a4b3221dba6ab4d9ee165134b07c40b90d6e16ea87f331ee80226d9ab0ae28823c8508a0dd7c8c5671a57f
7
- data.tar.gz: 5b2f6719689b4c047d3fa8a0b31dccd92457d5147eb40a0092331eb7b2f349297bdebd0b15b04702d0808bf154b6bbe69f9c2a7a83ddc71df80aae2fa3dbce0b
6
+ metadata.gz: 5bc3d992f6cc5d2f5a730efd765aae1d75ff2ec8665588d8387ff4faded3716f24f9b0b1680f8e9066cf4b05ebb3e008a6f91432a211af629434374398ceac49
7
+ data.tar.gz: c1a1f65604432f1156f34ec8d4ae3755f656a6647380bd068eda016fcaf5d79bbb5eabb6c5d63cb94a56be89ac6df007b96ab3b45351143a8513c34fd10ff241
@@ -178,4 +178,6 @@ def main
178
178
  end
179
179
  end
180
180
 
181
+ # simplecov:disable
181
182
  main if __FILE__ == $PROGRAM_NAME
183
+ # simplecov:enable
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Curlybars
2
4
  class << self
3
5
  attr_writer :configuration
@@ -13,14 +15,16 @@ module Curlybars
13
15
 
14
16
  def self.reset
15
17
  @configuration = Configuration.new
18
+ @global_helpers_dependency_tree = nil
16
19
  end
17
20
 
18
21
  class Configuration
19
- attr_accessor :presenters_namespace, :nesting_limit, :traversing_limit, :output_limit, :rendering_timeout, :custom_processors, :compiler_transformers, :global_helpers_provider_classes, :cache, :partial_nesting_limit, :partial_provider_class
22
+ attr_accessor :presenters_namespace, :nesting_limit, :traversing_limit, :output_limit, :rendering_timeout, :custom_processors, :compiler_transformers, :global_helpers_provider_classes, :cache, :partial_nesting_limit, :partial_provider_class, :parse_depth_limit
20
23
 
21
24
  def initialize
22
25
  @presenters_namespace = ''
23
26
  @nesting_limit = 10
27
+ @parse_depth_limit = Curlybars::Parser::DEFAULT_PARSE_DEPTH_LIMIT
24
28
  @traversing_limit = 10
25
29
  @output_limit = 1.megabyte
26
30
  @rendering_timeout = 10.seconds
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Curlybars
2
4
  class DependencyTracker
3
5
  def self.call(path, template)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Curlybars
2
4
  module Error
3
5
  class Base < StandardError
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'curlybars/error/base'
2
4
 
3
5
  module Curlybars
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'curlybars/error/base'
2
4
 
3
5
  module Curlybars
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'curlybars/error/base'
2
4
 
3
5
  module Curlybars
@@ -9,6 +11,8 @@ module Curlybars
9
11
  if exception.current.type == :EOS
10
12
  message = "A block helper hasn't been closed properly"
11
13
  position = EOSPosition.new(source)
14
+ elsif exception.is_a?(Curlybars::Parser::ParseDepthExceeded)
15
+ message = "Blocks and subexpressions cannot be nested more than %d levels deep" % exception.limit
12
16
  else
13
17
  line_number = position.line_number
14
18
  line_offset = position.line_offset
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Curlybars
2
4
  module Error
3
5
  module Presenter
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'curlybars/error/base'
2
4
 
3
5
  module Curlybars
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'curlybars/error/base'
2
4
 
3
5
  module Curlybars
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'curlybars/method_whitelist'
2
4
 
3
5
  module Curlybars
@@ -1,64 +1,170 @@
1
- require 'rltk/lexer'
1
+ # frozen_string_literal: true
2
+
3
+ require 'strscan'
4
+ require 'curlybars/token'
2
5
 
3
6
  # rubocop:disable Style/RegexpLiteral, Style/Semicolon
4
7
  module Curlybars
5
- class Lexer < RLTK::Lexer
6
- match_first
7
-
8
- # The following is an identifier Handlebars compliant
9
- # IDENTIFIER = '[A-Za-z_][0-9\w]*'
8
+ class Lexer
9
+ class Error < StandardError
10
+ attr_reader :stream_offset, :line_number, :line_offset, :remainder
11
+
12
+ def initialize(stream_offset, line_number, line_offset, remainder)
13
+ @stream_offset = stream_offset
14
+ @line_number = line_number
15
+ @line_offset = line_offset
16
+ @remainder = remainder
17
+ super("Unable to match string with any of the given rules: #{remainder}")
18
+ end
19
+ end
20
+
21
+ # Rules are tried in definition order and the first match wins. A rule
22
+ # can declare the bytes its matches start with (`first:`), and is then
23
+ # only tried when the next byte is one of them. Rules without `first:`
24
+ # are tried at every byte.
25
+ # Each rule belongs to a state; the current state is the top of a stack
26
+ # that rule actions manipulate with push_state and pop_state.
27
+ # Actions receive the matched text and can read capture groups with
28
+ # @scanner[n].
29
+ Rule = Data.define(:pattern, :action)
30
+
31
+ @rules = Hash.new { |hash, state| hash[state] = [] }
32
+ # For each state, the rules to try for each value of the next byte.
33
+ @dispatch = Hash.new { |hash, state| hash[state] = Array.new(256) { [] } }
34
+
35
+ class << self
36
+ attr_reader :rules, :dispatch
37
+
38
+ def r(pattern, state = :default, first: nil, &action)
39
+ rule = Rule.new(pattern, action || proc {})
40
+ @rules[state] << rule
41
+ (first ? first.bytes : 0..255).each { |byte| @dispatch[state][byte] << rule }
42
+ end
43
+
44
+ def lex(string, file_name = nil)
45
+ new(string, file_name).tokens
46
+ end
47
+ end
48
+
49
+ # The following is a Handlebars compliant identifier
50
+ # IDENTIFIER = '[A-Za-z_]\w*'
10
51
 
11
52
  # This accomodates the edge case of identifiers containing dashes
12
- # IDENTIFIER = '[A-Za-z_\-][0-9\w\-]*'
53
+ # IDENTIFIER = '[A-Za-z_\-][\w\-]*'
13
54
 
14
55
  # This accomodates the edge case of identifiers containing all numbers
15
56
  # and dashes
16
- IDENTIFIER = '[0-9A-Za-z_\-][0-9\w\-]*'.freeze
17
-
18
- r(/\\{/) { [:TEXT, '{'] }
19
- r(/\\/) { [:TEXT, '\\'] }
20
-
21
- r(/{{!--/) { push_state :comment_block }
22
- r(/--}}/, :comment_block) { pop_state }
23
- r(/./m, :comment_block)
24
-
25
- r(/{{!/) { push_state :comment }
26
- r(/}}/, :comment) { pop_state }
27
- r(/./m, :comment)
28
-
29
- r(/{{~/) { push_state :curly; :TILDE_START }
30
- r(/~}}/, :curly) { pop_state; :TILDE_END }
31
-
32
- r(/{{/) { push_state :curly; :START }
33
- r(/}}/, :curly) { pop_state; :END }
34
-
35
- r(/\(/, :curly) { push_state :curly; :LPAREN }
36
- r(/\)/, :curly) { pop_state; :RPAREN }
37
-
38
- r(/#/, :curly) { :HASH }
39
- r(/\//, :curly) { :SLASH }
40
- r(/>/, :curly) { :GT }
41
-
42
- r(/if\b/, :curly) { :IF }
43
- r(/unless\b/, :curly) { :UNLESS }
44
- r(/each\b/, :curly) { :EACH }
45
- r(/with\b/, :curly) { :WITH }
46
- r(/else\b/, :curly) { :ELSE }
47
-
48
- r(/true/, :curly) { [:LITERAL, true] }
49
- r(/false/, :curly) { [:LITERAL, false] }
50
- r(/[-+]?\d+/, :curly) { |integer| [:LITERAL, integer.to_i] }
51
- r(/'(.*?)'/, :curly) { [:LITERAL, match[1].inspect] }
52
- r(/"(.*?)"/, :curly) { [:LITERAL, match[1].inspect] }
53
-
54
- r(/@((?:\.\.\/)*#{IDENTIFIER})/o, :curly) { |variable| [:VARIABLE, match[1]] }
55
-
56
- r(/(#{IDENTIFIER})\s*=/o, :curly) { [:KEY, match[1]] }
57
- r(/(?:\.\.\/)*(?:#{IDENTIFIER}\.)*#{IDENTIFIER}/o, :curly) { |name| [:PATH, name] }
58
-
59
- r(/\s/, :curly)
60
-
61
- r(/.*?(?=\\|{{|\z)/m) { |text| [:TEXT, text] }
57
+ IDENTIFIER = '[\w\-]+'
58
+ IDENTIFIER_START = [*'0'..'9', *'A'..'Z', *'a'..'z', '_', '-'].join.freeze
59
+
60
+ r(/\\{/, first: '\\') { [:TEXT, '{'] }
61
+ r(/\\/, first: '\\') { [:TEXT, '\\'] }
62
+
63
+ # Comments are skipped up to their closing delimiter, or to the end of
64
+ # the template when they are not closed.
65
+ r(/{{!--.*?(?:--}}|\z)/m, first: '{')
66
+ r(/{{!.*?(?:}}|\z)/m, first: '{')
67
+
68
+ # The tilde operator strips whitespace from the adjacent text:
69
+ # `{{~` from the previous token and `~}}` from the next one.
70
+ r(/{{~/, first: '{') { rstrip_previous_text; push_state :curly; :START }
71
+ r(/~}}/, :curly, first: '~') { pop_state; lstrip_next_text; :END }
72
+
73
+ r(/{{/, first: '{') { push_state :curly; :START }
74
+ r(/}}/, :curly, first: '}') { pop_state; :END }
75
+
76
+ r(/\(/, :curly, first: '(') { push_state :curly; :LPAREN }
77
+ r(/\)/, :curly, first: ')') { pop_state; :RPAREN }
78
+
79
+ r(/#/, :curly, first: '#') { :HASH }
80
+ r(/\//, :curly, first: '/') { :SLASH }
81
+ r(/>/, :curly, first: '>') { :GT }
82
+
83
+ r(/if\b/, :curly, first: 'i') { :IF }
84
+ r(/unless\b/, :curly, first: 'u') { :UNLESS }
85
+ r(/each\b/, :curly, first: 'e') { :EACH }
86
+ r(/with\b/, :curly, first: 'w') { :WITH }
87
+ r(/else\b/, :curly, first: 'e') { :ELSE }
88
+
89
+ r(/true/, :curly, first: 't') { [:LITERAL, true] }
90
+ r(/false/, :curly, first: 'f') { [:LITERAL, false] }
91
+ r(/[-+]?\d+/, :curly, first: '-+0123456789') { |integer| [:LITERAL, integer.to_i] }
92
+ r(/'(.*?)'/, :curly, first: "'") { [:LITERAL, @scanner[1].inspect] }
93
+ r(/"(.*?)"/, :curly, first: '"') { [:LITERAL, @scanner[1].inspect] }
94
+
95
+ r(/@((?:\.\.\/)*#{IDENTIFIER})/o, :curly, first: '@') { [:VARIABLE, @scanner[1]] }
96
+
97
+ r(/(#{IDENTIFIER})\s*=/o, :curly, first: IDENTIFIER_START) { [:KEY, @scanner[1]] }
98
+ r(/(?:\.\.\/)*(?:#{IDENTIFIER}\.)*#{IDENTIFIER}/o, :curly, first: ".#{IDENTIFIER_START}") { |name| [:PATH, name] }
99
+
100
+ r(/\s+/, :curly, first: " \t\n\v\f\r")
101
+
102
+ r(/.*?(?=\\|{{|\z)/m) { |text| [:TEXT, @tokens.length == @lstrip_index ? text.lstrip : text] }
103
+
104
+ def initialize(string, file_name)
105
+ @string = string
106
+ @scanner = StringScanner.new(string)
107
+ @file_name = file_name
108
+ @states = [:default]
109
+ @tokens = []
110
+ @lstrip_index = nil
111
+ end
112
+
113
+ def tokens
114
+ stream_offset = 0
115
+ line_number = 1
116
+ line_offset = 0
117
+
118
+ until @scanner.eos?
119
+ text = nil
120
+ candidates = self.class.dispatch[@states.last][@string.getbyte(@scanner.pos)]
121
+ rule = candidates.detect { |candidate| text = @scanner.scan(candidate.pattern) }
122
+ raise Error.new(stream_offset, line_number, line_offset, @scanner.rest) unless rule
123
+
124
+ type, value = instance_exec(text, &rule.action)
125
+
126
+ if type
127
+ position = StreamPosition.new(stream_offset, line_number, line_offset, text.length, @file_name)
128
+ @tokens << Token.new(type, value, position)
129
+ end
130
+
131
+ stream_offset += text.length
132
+ newlines = text.count("\n")
133
+ if newlines > 0
134
+ line_number += newlines
135
+ line_offset = text.length - text.rindex("\n") - 1
136
+ else
137
+ line_offset += text.length
138
+ end
139
+ end
140
+
141
+ @tokens << Token::EOS
142
+ end
143
+
144
+ private
145
+
146
+ def push_state(state)
147
+ @states.push(state)
148
+ nil
149
+ end
150
+
151
+ def pop_state
152
+ @states.pop
153
+ nil
154
+ end
155
+
156
+ def rstrip_previous_text
157
+ previous = @tokens.last
158
+ return unless previous&.type == :TEXT
159
+
160
+ @tokens[-1] = Token.new(:TEXT, previous.value.rstrip, previous.position)
161
+ end
162
+
163
+ # The rule calling this emits a token at index @tokens.length, so the
164
+ # following token lands at @tokens.length + 1.
165
+ def lstrip_next_text
166
+ @lstrip_index = @tokens.length + 1
167
+ end
62
168
  end
63
169
  end
64
170
  # rubocop:enable Style/RegexpLiteral, Style/Semicolon
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Curlybars
2
4
  module MethodWhitelist
3
5
  def allow_methods(*methods_without_type, **methods_with_type, &contextual_block)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'curlybars/error/compile'
2
4
 
3
5
  module Curlybars
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Curlybars
2
4
  module Node
3
5
  EachElse = Struct.new(:path, :each_template, :else_template, :position) do
@@ -12,6 +14,7 @@ module Curlybars
12
14
  template_cache_key = '#{each_template.cache_key}'
13
15
 
14
16
  collection = rendering.coerce_to_hash!(collection, #{collection_path.path.inspect}, position)
17
+ rendering.check_nesting_not_too_deep(position)
15
18
  collection.each.with_index.map do |key_and_presenter, index|
16
19
  rendering.check_timeout!
17
20
  rendering.optional_presenter_cache(key_and_presenter[1], template_cache_key, buffer) do |buffer|
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Curlybars
2
4
  module Node
3
5
  IfElse = Struct.new(:expression, :if_template, :else_template) do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Curlybars
2
4
  module Node
3
5
  Item = Struct.new(:item) do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Curlybars
2
4
  module Node
3
5
  Literal = Struct.new(:literal) do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Curlybars
2
4
  module Node
3
5
  Option = Struct.new(:key, :expression) do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Curlybars
2
4
  module Node
3
5
  Output = Struct.new(:value) do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Curlybars
2
4
  module Node
3
5
  Partial = Struct.new(:path, :options, :position) do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Curlybars
2
4
  module Node
3
5
  Path = Struct.new(:path, :position) do
@@ -168,11 +170,6 @@ module Curlybars
168
170
 
169
171
  message = "`#{path}` cannot resolve to a helper"
170
172
  raise Curlybars::Error::Validate.new('not_a_helper', message, position)
171
- when :not_helper
172
- return unless helper?(branches)
173
-
174
- message = "`#{path}` resolves to a helper"
175
- raise Curlybars::Error::Validate.new('is_a_helper', message, position)
176
173
  when :anything
177
174
  else
178
175
  raise "invalid type `#{check_type}`"
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Curlybars
2
4
  module Node
3
5
  Root = Struct.new(:template, :position) do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Curlybars
2
4
  module Node
3
5
  SubExpression = Struct.new(:helper, :arguments, :options, :position) do
@@ -63,22 +65,19 @@ module Curlybars
63
65
 
64
66
  type = node.resolve_and_check!(branches, check_type: check_type)
65
67
 
66
- if helper?(type)
67
- if generic_helper?(type)
68
- is_collection = type.last.is_a?(Array)
69
- return infer_generic_helper_type!(branches, is_collection: is_collection)
70
- end
71
-
72
- return type.last
68
+ if generic_helper?(type)
69
+ is_collection = type.last.is_a?(Array)
70
+ infer_generic_helper_type!(branches, is_collection: is_collection)
71
+ elsif helper?(type)
72
+ type.last
73
+ else
74
+ type
73
75
  end
74
-
75
- type
76
76
  end
77
77
 
78
78
  def generic_helper?(type)
79
- return false unless type.is_a?(Array)
79
+ return false unless helper?(type)
80
80
  return false unless type.size == 2
81
- return false unless type.first == :helper
82
81
 
83
82
  type.last == [{}] || type.last == {}
84
83
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Curlybars
2
4
  module Node
3
5
  Template = Struct.new(:items, :position) do
@@ -9,11 +11,6 @@ module Curlybars
9
11
  <<-RUBY
10
12
  ::Module.new do
11
13
  def self.exec(contexts, rendering, variables, buffer)
12
- unless contexts.length < ::Curlybars.configuration.nesting_limit
13
- message = "Nesting too deep"
14
- position = rendering.position(#{position.line_number}, #{position.line_offset})
15
- raise ::Curlybars::Error::Render.new('nesting_too_deep', message, position)
16
- end
17
14
  #{compiled_items}
18
15
  end
19
16
  end.exec(contexts, rendering, variables, buffer)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Curlybars
2
4
  module Node
3
5
  Text = Struct.new(:text) do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Curlybars
2
4
  module Node
3
5
  UnlessElse = Struct.new(:expression, :unless_template, :else_template) do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Curlybars
2
4
  module Node
3
5
  Variable = Struct.new(:variable, :position) do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Curlybars
2
4
  module Node
3
5
  WithElse = Struct.new(:path, :with_template, :else_template, :position) do
@@ -10,6 +12,7 @@ module Curlybars
10
12
  if rendering.to_bool(compiled_path)
11
13
  position = rendering.position(#{position.line_number}, #{position.line_offset})
12
14
  rendering.check_context_is_presenter(compiled_path, #{presenter_path.path.inspect}, position)
15
+ rendering.check_nesting_not_too_deep(position)
13
16
 
14
17
  contexts.push(compiled_path)
15
18
  begin