@@ -128,7 +128,10 @@ protected function initialize() {
128128 // Sections
129129 $ this ->withHandler ('# ' , true , function ($ tag , $ state , $ parse ) {
130130 $ state ->parents []= $ state ->target ;
131- $ block = $ this ->blocks ->newInstance ($ parse ->options (trim (substr ($ tag , 1 ))), $ state );
131+ $ block = $ state ->target ->add ($ this ->blocks ->newInstance (
132+ $ parse ->options (trim (substr ($ tag , 1 ))),
133+ $ state
134+ ));
132135 $ state ->target = $ block ->fn ();
133136 $ state ->parents []= $ block ;
134137 });
@@ -204,7 +207,10 @@ protected function initialize() {
204207 $ state ->target = $ block ->inverse ();
205208 } else {
206209 $ state ->parents []= $ state ->target ;
207- $ block = new InverseOf ($ this ->blocks ->newInstance ($ parse ->options (substr ($ tag , 1 )), $ state ));
210+ $ block = new InverseOf ($ state ->target ->add ($ this ->blocks ->newInstance (
211+ $ parse ->options (substr ($ tag , 1 )),
212+ $ state
213+ )));
208214 $ state ->target = $ block ->fn ();
209215 $ state ->parents []= $ block ;
210216 }
@@ -223,14 +229,11 @@ protected function initialize() {
223229 $ context = &$ state ->parents [sizeof ($ state ->parents ) - 1 ];
224230 if ($ context instanceof BlockNode) {
225231
226- // `else if` vs. `else`
227- if (isset ($ parsed [1 ]) && 'if ' === (string )$ parsed [1 ]) {
228- $ context = $ context ->inverse ()->add (new IfBlockHelper (
229- array_slice ($ parsed , 2 ),
230- null ,
231- null ,
232- $ state ->start ,
233- $ state ->end
232+ // `else [...]` vs. `else`
233+ if (isset ($ parsed [1 ])) {
234+ $ context = $ context ->inverse ()->add ($ this ->blocks ->newInstance (
235+ array_slice ($ parsed , 1 ),
236+ $ state
234237 ));
235238 $ state ->target = $ context ->fn ();
236239 } else {
0 commit comments